0s autopkgtest [17:23:36]: starting date and time: 2025-05-06 17:23:36+0000 0s autopkgtest [17:23:36]: git checkout: 9986aa8c Merge branch 'skia/fix_network_interface' into 'ubuntu/production' 0s autopkgtest [17:23:36]: host juju-7f2275-prod-proposed-migration-environment-15; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.ppe4q4h2/out --timeout-copy=6000 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:python-xarray,src:matplotlib --apt-upgrade pandas --timeout-short=300 --timeout-copy=20000 --timeout-test=20000 --timeout-build=20000 '--env=ADT_TEST_TRIGGERS=python-xarray/2025.03.1-8 matplotlib/3.10.1+dfsg1-3' -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor autopkgtest-big-ppc64el --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-15@bos03-ppc64el-11.secgroup --name adt-questing-ppc64el-pandas-20250506-172336-juju-7f2275-prod-proposed-migration-environment-15-1b8f1c3a-b860-4252-902a-e27f31f93f66 --image adt/ubuntu-questing-ppc64el-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-15 --net-id=net_prod-proposed-migration-ppc64el -e TERM=linux --mirror=http://ftpmaster.internal/ubuntu/ 96s autopkgtest [17:25:12]: testbed dpkg architecture: ppc64el 96s autopkgtest [17:25:12]: testbed apt version: 3.0.0 97s autopkgtest [17:25:13]: @@@@@@@@@@@@@@@@@@@@ test bed setup 97s autopkgtest [17:25:13]: testbed release detected to be: None 98s autopkgtest [17:25:14]: updating testbed package index (apt update) 98s Get:1 http://ftpmaster.internal/ubuntu questing-proposed InRelease [110 kB] 98s Hit:2 http://ftpmaster.internal/ubuntu questing InRelease 98s Hit:3 http://ftpmaster.internal/ubuntu questing-updates InRelease 98s Hit:4 http://ftpmaster.internal/ubuntu questing-security InRelease 98s Get:5 http://ftpmaster.internal/ubuntu questing-proposed/main Sources [67.8 kB] 98s Get:6 http://ftpmaster.internal/ubuntu questing-proposed/universe Sources [580 kB] 99s Get:7 http://ftpmaster.internal/ubuntu questing-proposed/multiverse Sources [27.3 kB] 99s Get:8 http://ftpmaster.internal/ubuntu questing-proposed/main ppc64el Packages [131 kB] 99s Get:9 http://ftpmaster.internal/ubuntu questing-proposed/universe ppc64el Packages [592 kB] 99s Get:10 http://ftpmaster.internal/ubuntu questing-proposed/multiverse ppc64el Packages [18.1 kB] 99s Fetched 1527 kB in 1s (1626 kB/s) 100s Reading package lists... 101s autopkgtest [17:25:17]: upgrading testbed (apt dist-upgrade and autopurge) 101s Reading package lists... 101s Building dependency tree... 101s Reading state information... 102s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 102s Starting 2 pkgProblemResolver with broken count: 0 102s Done 102s Entering ResolveByKeep 103s 103s Calculating upgrade... 103s The following packages will be upgraded: 103s gcc-15-base libatomic1 libgcc-s1 libpython3.12-minimal libpython3.12-stdlib 103s libpython3.12t64 libstdc++6 sensible-utils 103s 8 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 103s Need to get 6554 kB of archives. 103s After this operation, 159 kB disk space will be freed. 103s Get:1 http://ftpmaster.internal/ubuntu questing/main ppc64el libatomic1 ppc64el 15.1.0-2ubuntu1 [11.0 kB] 103s Get:2 http://ftpmaster.internal/ubuntu questing/main ppc64el gcc-15-base ppc64el 15.1.0-2ubuntu1 [54.7 kB] 103s Get:3 http://ftpmaster.internal/ubuntu questing/main ppc64el libgcc-s1 ppc64el 15.1.0-2ubuntu1 [40.1 kB] 103s Get:4 http://ftpmaster.internal/ubuntu questing/main ppc64el libstdc++6 ppc64el 15.1.0-2ubuntu1 [920 kB] 104s Get:5 http://ftpmaster.internal/ubuntu questing/main ppc64el sensible-utils all 0.0.25 [25.0 kB] 104s Get:6 http://ftpmaster.internal/ubuntu questing-proposed/universe ppc64el libpython3.12t64 ppc64el 3.12.10-1 [2558 kB] 104s Get:7 http://ftpmaster.internal/ubuntu questing-proposed/universe ppc64el libpython3.12-stdlib ppc64el 3.12.10-1 [2105 kB] 104s Get:8 http://ftpmaster.internal/ubuntu questing-proposed/universe ppc64el libpython3.12-minimal ppc64el 3.12.10-1 [841 kB] 104s Fetched 6554 kB in 1s (7862 kB/s) 105s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 107214 files and directories currently installed.) 105s Preparing to unpack .../libatomic1_15.1.0-2ubuntu1_ppc64el.deb ... 105s Unpacking libatomic1:ppc64el (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 105s Preparing to unpack .../gcc-15-base_15.1.0-2ubuntu1_ppc64el.deb ... 105s Unpacking gcc-15-base:ppc64el (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 105s Setting up gcc-15-base:ppc64el (15.1.0-2ubuntu1) ... 105s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 107214 files and directories currently installed.) 105s Preparing to unpack .../libgcc-s1_15.1.0-2ubuntu1_ppc64el.deb ... 105s Unpacking libgcc-s1:ppc64el (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 105s Setting up libgcc-s1:ppc64el (15.1.0-2ubuntu1) ... 105s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 107214 files and directories currently installed.) 105s Preparing to unpack .../libstdc++6_15.1.0-2ubuntu1_ppc64el.deb ... 105s Unpacking libstdc++6:ppc64el (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 105s Setting up libstdc++6:ppc64el (15.1.0-2ubuntu1) ... 105s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 107214 files and directories currently installed.) 105s Preparing to unpack .../sensible-utils_0.0.25_all.deb ... 105s Unpacking sensible-utils (0.0.25) over (0.0.24) ... 105s Preparing to unpack .../libpython3.12t64_3.12.10-1_ppc64el.deb ... 105s Unpacking libpython3.12t64:ppc64el (3.12.10-1) over (3.12.8-3) ... 105s Preparing to unpack .../libpython3.12-stdlib_3.12.10-1_ppc64el.deb ... 105s Unpacking libpython3.12-stdlib:ppc64el (3.12.10-1) over (3.12.8-3) ... 105s Preparing to unpack .../libpython3.12-minimal_3.12.10-1_ppc64el.deb ... 105s Unpacking libpython3.12-minimal:ppc64el (3.12.10-1) over (3.12.8-3) ... 105s Setting up libpython3.12-minimal:ppc64el (3.12.10-1) ... 105s Setting up libatomic1:ppc64el (15.1.0-2ubuntu1) ... 105s Setting up sensible-utils (0.0.25) ... 105s Setting up libpython3.12-stdlib:ppc64el (3.12.10-1) ... 105s Setting up libpython3.12t64:ppc64el (3.12.10-1) ... 105s Processing triggers for man-db (2.13.1-1) ... 106s Processing triggers for libc-bin (2.41-6ubuntu1) ... 107s Reading package lists... 107s Building dependency tree... 107s Reading state information... 107s Starting pkgProblemResolver with broken count: 0 107s Starting 2 pkgProblemResolver with broken count: 0 107s Done 108s Solving dependencies... 108s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 110s autopkgtest [17:25:26]: testbed running kernel: Linux 6.14.0-15-generic #15-Ubuntu SMP Sun Apr 6 14:52:42 UTC 2025 111s autopkgtest [17:25:27]: @@@@@@@@@@@@@@@@@@@@ apt-source pandas 114s Get:1 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (dsc) [5546 B] 114s Get:2 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (tar) [11.2 MB] 114s Get:3 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (diff) [112 kB] 115s gpgv: Signature made Sat Mar 29 14:46:18 2025 UTC 115s gpgv: using RSA key 67CB311005C4EDBE32175308DEE50D0D567EA266 115s gpgv: issuer "rebecca_palmer@zoho.com" 115s gpgv: Can't check signature: No public key 115s dpkg-source: warning: cannot verify inline signature for ./pandas_2.2.3+dfsg-9.dsc: no acceptable signature found 116s autopkgtest [17:25:32]: testing package pandas version 2.2.3+dfsg-9 117s autopkgtest [17:25:33]: build not needed 131s autopkgtest [17:25:47]: test command1: preparing testbed 131s Reading package lists... 131s Building dependency tree... 131s Reading state information... 132s Starting pkgProblemResolver with broken count: 0 132s Starting 2 pkgProblemResolver with broken count: 0 132s Done 132s The following NEW packages will be installed: 132s libblas3 libgfortran5 liblapack3 python3-dateutil python3-numpy 132s python3-numpy-dev python3-pandas python3-pandas-lib python3-pytz 133s 0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. 133s Need to get 16.9 MB of archives. 133s After this operation, 89.4 MB of additional disk space will be used. 133s Get:1 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-numpy-dev ppc64el 1:2.2.4+ds-1 [154 kB] 133s Get:2 http://ftpmaster.internal/ubuntu questing/main ppc64el libblas3 ppc64el 3.12.1-2 [239 kB] 133s Get:3 http://ftpmaster.internal/ubuntu questing/main ppc64el libgfortran5 ppc64el 15.1.0-2ubuntu1 [614 kB] 133s Get:4 http://ftpmaster.internal/ubuntu questing/main ppc64el liblapack3 ppc64el 3.12.1-2 [2813 kB] 133s Get:5 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-numpy ppc64el 1:2.2.4+ds-1 [4853 kB] 133s Get:6 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-dateutil all 2.9.0-4 [80.3 kB] 133s Get:7 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-pytz all 2025.1-3 [162 kB] 133s Get:8 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pandas-lib ppc64el 2.2.3+dfsg-9 [4865 kB] 133s Get:9 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pandas all 2.2.3+dfsg-9 [3112 kB] 134s Fetched 16.9 MB in 1s (16.7 MB/s) 134s Selecting previously unselected package python3-numpy-dev:ppc64el. 134s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 107214 files and directories currently installed.) 134s Preparing to unpack .../0-python3-numpy-dev_1%3a2.2.4+ds-1_ppc64el.deb ... 134s Unpacking python3-numpy-dev:ppc64el (1:2.2.4+ds-1) ... 134s Selecting previously unselected package libblas3:ppc64el. 134s Preparing to unpack .../1-libblas3_3.12.1-2_ppc64el.deb ... 134s Unpacking libblas3:ppc64el (3.12.1-2) ... 134s Selecting previously unselected package libgfortran5:ppc64el. 134s Preparing to unpack .../2-libgfortran5_15.1.0-2ubuntu1_ppc64el.deb ... 134s Unpacking libgfortran5:ppc64el (15.1.0-2ubuntu1) ... 134s Selecting previously unselected package liblapack3:ppc64el. 134s Preparing to unpack .../3-liblapack3_3.12.1-2_ppc64el.deb ... 134s Unpacking liblapack3:ppc64el (3.12.1-2) ... 134s Selecting previously unselected package python3-numpy. 134s Preparing to unpack .../4-python3-numpy_1%3a2.2.4+ds-1_ppc64el.deb ... 134s Unpacking python3-numpy (1:2.2.4+ds-1) ... 134s Selecting previously unselected package python3-dateutil. 134s Preparing to unpack .../5-python3-dateutil_2.9.0-4_all.deb ... 134s Unpacking python3-dateutil (2.9.0-4) ... 134s Selecting previously unselected package python3-pytz. 134s Preparing to unpack .../6-python3-pytz_2025.1-3_all.deb ... 134s Unpacking python3-pytz (2025.1-3) ... 134s Selecting previously unselected package python3-pandas-lib:ppc64el. 134s Preparing to unpack .../7-python3-pandas-lib_2.2.3+dfsg-9_ppc64el.deb ... 134s Unpacking python3-pandas-lib:ppc64el (2.2.3+dfsg-9) ... 135s Selecting previously unselected package python3-pandas. 135s Preparing to unpack .../8-python3-pandas_2.2.3+dfsg-9_all.deb ... 135s Unpacking python3-pandas (2.2.3+dfsg-9) ... 135s Setting up python3-pytz (2025.1-3) ... 135s Setting up libblas3:ppc64el (3.12.1-2) ... 135s update-alternatives: using /usr/lib/powerpc64le-linux-gnu/blas/libblas.so.3 to provide /usr/lib/powerpc64le-linux-gnu/libblas.so.3 (libblas.so.3-powerpc64le-linux-gnu) in auto mode 135s Setting up python3-numpy-dev:ppc64el (1:2.2.4+ds-1) ... 135s Setting up libgfortran5:ppc64el (15.1.0-2ubuntu1) ... 135s Setting up python3-dateutil (2.9.0-4) ... 135s Setting up liblapack3:ppc64el (3.12.1-2) ... 135s update-alternatives: using /usr/lib/powerpc64le-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/powerpc64le-linux-gnu/liblapack.so.3 (liblapack.so.3-powerpc64le-linux-gnu) in auto mode 135s Setting up python3-numpy (1:2.2.4+ds-1) ... 137s Setting up python3-pandas-lib:ppc64el (2.2.3+dfsg-9) ... 137s Setting up python3-pandas (2.2.3+dfsg-9) ... 143s Processing triggers for man-db (2.13.1-1) ... 143s Processing triggers for libc-bin (2.41-6ubuntu1) ... 144s autopkgtest [17:26:00]: test command1: cd "$AUTOPKGTEST_TMP" && python3 -c "import pandas;a=pandas.DataFrame([[1,2],[3,4]])" 144s autopkgtest [17:26:00]: test command1: [----------------------- 145s autopkgtest [17:26:01]: test command1: -----------------------] 146s autopkgtest [17:26:02]: test command1: - - - - - - - - - - results - - - - - - - - - - 146s command1 PASS 146s autopkgtest [17:26:02]: test unittests3: preparing testbed 146s Reading package lists... 147s Building dependency tree... 147s Reading state information... 147s Starting pkgProblemResolver with broken count: 0 147s Starting 2 pkgProblemResolver with broken count: 0 147s Done 148s The following NEW packages will be installed: 148s blt fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 148s fonts-lyx libaec0 libavahi-client3 libavahi-common-data libavahi-common3 148s libblosc1 libblosc2-4 libcups2t64 libdeflate0 libdouble-conversion3 148s libegl-mesa0 libegl1 libfontconfig1 libfontenc1 libgbm1 libgl1 148s libgl1-mesa-dri libglvnd0 libglx-mesa0 libglx0 libgomp1 libgraphite2-3 148s libharfbuzz0b libhdf5-310 libice6 libimagequant0 libinput-bin libinput10 148s libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-jquery-ui liblbfgsb0 148s liblcms2-2 liblerc4 libmd4c0 libmtdev1t64 libopenjp2-7 libpcre2-16-0 148s libpixman-1-0 libqhull-r8.0 libqt5core5t64 libqt5dbus5t64 libqt5designer5 148s libqt5gui5t64 libqt5help5 libqt5network5t64 libqt5printsupport5t64 148s libqt5sql5t64 libqt5test5t64 libqt5widgets5t64 libqt5xml5t64 libraqm0 148s libsharpyuv0 libsm6 libsnappy1v5 libsz2 libtcl8.6 libtiff6 libtk8.6 148s libvulkan1 libwacom-common libwacom9 libwayland-client0 libwayland-server0 148s libwebp7 libwebpdemux2 libwebpmux3 libx11-xcb1 libxaw7 libxcb-dri3-0 148s libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-present0 148s libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 148s libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb-xinput0 148s libxcb-xkb1 libxfont2 libxft2 libxkbcommon-x11-0 libxkbfile1 libxmu6 libxpm4 148s libxrandr2 libxrender1 libxshmfence1 libxslt1.1 libxss1 libxt6t64 148s libxxf86vm1 locales-all mesa-libgallium python-matplotlib-data 148s python-tables-data python3-all python3-async-generator python3-bottleneck 148s python3-brotli python3-bs4 python3-click python3-cloudpickle 148s python3-contourpy python3-cpuinfo python3-cycler python3-dask 148s python3-decorator python3-defusedxml python3-et-xmlfile python3-execnet 148s python3-fonttools python3-fs python3-fsspec python3-greenlet 148s python3-html5lib python3-hypothesis python3-iniconfig python3-kiwisolver 148s python3-locket python3-lxml python3-lz4 python3-matplotlib python3-mpmath 148s python3-numexpr python3-odf python3-openpyxl python3-packaging python3-partd 148s python3-pil python3-pil.imagetk python3-platformdirs python3-pluggy 148s python3-py python3-pyqt5 python3-pyqt5.sip python3-pyreadstat python3-pytest 148s python3-pytest-asyncio python3-pytest-forked python3-pytest-localserver 148s python3-pytest-xdist python3-pytestqt python3-scipy python3-sortedcontainers 148s python3-soupsieve python3-sqlalchemy python3-sympy python3-tables 148s python3-tables-lib python3-tabulate python3-tk python3-toolz python3-tz 148s python3-ufolib2 python3-webencodings python3-werkzeug python3-xarray 148s python3-xlrd python3-xlsxwriter python3-zstandard python3.13-tk tk8.6-blt2.5 148s tzdata-legacy unicode-data x11-common x11-xkb-utils xsel xserver-common xvfb 148s 0 upgraded, 184 newly installed, 0 to remove and 0 not upgraded. 148s Need to get 119 MB of archives. 148s After this operation, 705 MB of additional disk space will be used. 148s Get:1 http://ftpmaster.internal/ubuntu questing/main ppc64el libtcl8.6 ppc64el 8.6.16+dfsg-1 [1201 kB] 149s Get:2 http://ftpmaster.internal/ubuntu questing/main ppc64el fonts-dejavu-mono all 2.37-8 [502 kB] 149s Get:3 http://ftpmaster.internal/ubuntu questing/main ppc64el fonts-dejavu-core all 2.37-8 [835 kB] 149s Get:4 http://ftpmaster.internal/ubuntu questing/main ppc64el fontconfig-config ppc64el 2.15.0-2.2ubuntu1 [37.9 kB] 149s Get:5 http://ftpmaster.internal/ubuntu questing/main ppc64el libfontconfig1 ppc64el 2.15.0-2.2ubuntu1 [187 kB] 149s Get:6 http://ftpmaster.internal/ubuntu questing/main ppc64el libxrender1 ppc64el 1:0.9.12-1 [23.0 kB] 149s Get:7 http://ftpmaster.internal/ubuntu questing/main ppc64el libxft2 ppc64el 2.3.6-1build1 [61.5 kB] 149s Get:8 http://ftpmaster.internal/ubuntu questing/main ppc64el x11-common all 1:7.7+23ubuntu4 [21.8 kB] 149s Get:9 http://ftpmaster.internal/ubuntu questing/main ppc64el libxss1 ppc64el 1:1.2.3-1build3 [7980 B] 149s Get:10 http://ftpmaster.internal/ubuntu questing/main ppc64el libtk8.6 ppc64el 8.6.16-1 [946 kB] 149s Get:11 http://ftpmaster.internal/ubuntu questing/main ppc64el tk8.6-blt2.5 ppc64el 2.5.3+dfsg-8 [778 kB] 150s Get:12 http://ftpmaster.internal/ubuntu questing/main ppc64el blt ppc64el 2.5.3+dfsg-8 [4830 B] 150s Get:13 http://ftpmaster.internal/ubuntu questing/main ppc64el fontconfig ppc64el 2.15.0-2.2ubuntu1 [192 kB] 150s Get:14 http://ftpmaster.internal/ubuntu questing/universe ppc64el fonts-lyx all 2.4.3-1 [171 kB] 150s Get:15 http://ftpmaster.internal/ubuntu questing/universe ppc64el libaec0 ppc64el 1.1.3-1 [30.1 kB] 150s Get:16 http://ftpmaster.internal/ubuntu questing/main ppc64el libavahi-common-data ppc64el 0.8-16ubuntu2 [31.0 kB] 150s Get:17 http://ftpmaster.internal/ubuntu questing/main ppc64el libavahi-common3 ppc64el 0.8-16ubuntu2 [25.9 kB] 150s Get:18 http://ftpmaster.internal/ubuntu questing/main ppc64el libavahi-client3 ppc64el 0.8-16ubuntu2 [30.9 kB] 150s Get:19 http://ftpmaster.internal/ubuntu questing/main ppc64el libsnappy1v5 ppc64el 1.2.2-1 [33.8 kB] 150s Get:20 http://ftpmaster.internal/ubuntu questing/universe ppc64el libblosc1 ppc64el 1.21.5+ds-1build1 [38.5 kB] 150s Get:21 http://ftpmaster.internal/ubuntu questing/universe ppc64el libblosc2-4 ppc64el 2.17.1+ds-1 [195 kB] 150s Get:22 http://ftpmaster.internal/ubuntu questing/main ppc64el libcups2t64 ppc64el 2.4.12-0ubuntu1 [348 kB] 150s Get:23 http://ftpmaster.internal/ubuntu questing/main ppc64el libdeflate0 ppc64el 1.23-2 [63.3 kB] 150s Get:24 http://ftpmaster.internal/ubuntu questing/universe ppc64el libdouble-conversion3 ppc64el 3.3.1-1 [46.3 kB] 150s Get:25 http://ftpmaster.internal/ubuntu questing/main ppc64el libwayland-server0 ppc64el 1.23.1-3 [42.4 kB] 150s Get:26 http://ftpmaster.internal/ubuntu questing/main ppc64el libx11-xcb1 ppc64el 2:1.8.12-1 [8014 B] 150s Get:27 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-dri3-0 ppc64el 1.17.0-2 [7842 B] 150s Get:28 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-present0 ppc64el 1.17.0-2 [6276 B] 150s Get:29 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-randr0 ppc64el 1.17.0-2 [19.1 kB] 150s Get:30 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-sync1 ppc64el 1.17.0-2 [9804 B] 150s Get:31 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-xfixes0 ppc64el 1.17.0-2 [10.7 kB] 150s Get:32 http://ftpmaster.internal/ubuntu questing/main ppc64el libxshmfence1 ppc64el 1.3.3-1 [5364 B] 150s Get:33 http://ftpmaster.internal/ubuntu questing/main ppc64el mesa-libgallium ppc64el 25.0.3-1ubuntu2 [9535 kB] 152s Get:34 http://ftpmaster.internal/ubuntu questing/main ppc64el libgbm1 ppc64el 25.0.3-1ubuntu2 [39.1 kB] 152s Get:35 http://ftpmaster.internal/ubuntu questing/main ppc64el libwayland-client0 ppc64el 1.23.1-3 [31.7 kB] 152s Get:36 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-shm0 ppc64el 1.17.0-2 [5980 B] 152s Get:37 http://ftpmaster.internal/ubuntu questing/main ppc64el libegl-mesa0 ppc64el 25.0.3-1ubuntu2 [152 kB] 152s Get:38 http://ftpmaster.internal/ubuntu questing/main ppc64el libfontenc1 ppc64el 1:1.1.8-1build1 [15.8 kB] 152s Get:39 http://ftpmaster.internal/ubuntu questing/main ppc64el libvulkan1 ppc64el 1.4.309.0-1 [162 kB] 152s Get:40 http://ftpmaster.internal/ubuntu questing/main ppc64el libgl1-mesa-dri ppc64el 25.0.3-1ubuntu2 [35.1 kB] 152s Get:41 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-glx0 ppc64el 1.17.0-2 [26.3 kB] 152s Get:42 http://ftpmaster.internal/ubuntu questing/main ppc64el libxxf86vm1 ppc64el 1:1.1.4-1build4 [11.1 kB] 152s Get:43 http://ftpmaster.internal/ubuntu questing/main ppc64el libglx-mesa0 ppc64el 25.0.3-1ubuntu2 [175 kB] 152s Get:44 http://ftpmaster.internal/ubuntu questing/main ppc64el libgomp1 ppc64el 15.1.0-2ubuntu1 [169 kB] 152s Get:45 http://ftpmaster.internal/ubuntu questing/main ppc64el libgraphite2-3 ppc64el 1.3.14-2ubuntu1 [84.6 kB] 152s Get:46 http://ftpmaster.internal/ubuntu questing/main ppc64el libharfbuzz0b ppc64el 10.2.0-1 [598 kB] 153s Get:47 http://ftpmaster.internal/ubuntu questing/universe ppc64el libsz2 ppc64el 1.1.3-1 [5566 B] 153s Get:48 http://ftpmaster.internal/ubuntu questing/universe ppc64el libhdf5-310 ppc64el 1.14.5+repack-3 [1523 kB] 153s Get:49 http://ftpmaster.internal/ubuntu questing/main ppc64el libice6 ppc64el 2:1.1.1-1 [49.9 kB] 153s Get:50 http://ftpmaster.internal/ubuntu questing/main ppc64el libimagequant0 ppc64el 2.18.0-1build1 [43.2 kB] 153s Get:51 http://ftpmaster.internal/ubuntu questing/main ppc64el libwacom-common all 2.14.0-1 [103 kB] 153s Get:52 http://ftpmaster.internal/ubuntu questing/main ppc64el libwacom9 ppc64el 2.14.0-1 [32.5 kB] 153s Get:53 http://ftpmaster.internal/ubuntu questing/main ppc64el libinput-bin ppc64el 1.28.1-1 [24.3 kB] 153s Get:54 http://ftpmaster.internal/ubuntu questing/main ppc64el libmtdev1t64 ppc64el 1.1.7-1 [18.5 kB] 153s Get:55 http://ftpmaster.internal/ubuntu questing/main ppc64el libinput10 ppc64el 1.28.1-1 [169 kB] 153s Get:56 http://ftpmaster.internal/ubuntu questing/main ppc64el libjpeg-turbo8 ppc64el 2.1.5-3ubuntu2 [215 kB] 153s Get:57 http://ftpmaster.internal/ubuntu questing/main ppc64el libjpeg8 ppc64el 8c-2ubuntu11 [2148 B] 153s Get:58 http://ftpmaster.internal/ubuntu questing/main ppc64el libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 153s Get:59 http://ftpmaster.internal/ubuntu questing/universe ppc64el libjs-jquery-ui all 1.13.2+dfsg-1 [252 kB] 153s Get:60 http://ftpmaster.internal/ubuntu questing/universe ppc64el liblbfgsb0 ppc64el 3.0+dfsg.4-1build1 [33.0 kB] 153s Get:61 http://ftpmaster.internal/ubuntu questing/main ppc64el liblcms2-2 ppc64el 2.16-2 [243 kB] 153s Get:62 http://ftpmaster.internal/ubuntu questing/main ppc64el liblerc4 ppc64el 4.0.0+ds-5ubuntu1 [298 kB] 153s Get:63 http://ftpmaster.internal/ubuntu questing/universe ppc64el libmd4c0 ppc64el 0.5.2-2 [54.5 kB] 153s Get:64 http://ftpmaster.internal/ubuntu questing/main ppc64el libpcre2-16-0 ppc64el 10.45-1 [286 kB] 154s Get:65 http://ftpmaster.internal/ubuntu questing/main ppc64el libpixman-1-0 ppc64el 0.44.0-3 [334 kB] 154s Get:66 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqhull-r8.0 ppc64el 2020.2-6build1 [225 kB] 154s Get:67 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqt5core5t64 ppc64el 5.15.15+dfsg-4ubuntu1 [2188 kB] 154s Get:68 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqt5dbus5t64 ppc64el 5.15.15+dfsg-4ubuntu1 [242 kB] 154s Get:69 http://ftpmaster.internal/ubuntu questing/main ppc64el libglvnd0 ppc64el 1.7.0-1build1 [72.4 kB] 154s Get:70 http://ftpmaster.internal/ubuntu questing/main ppc64el libegl1 ppc64el 1.7.0-1build1 [34.1 kB] 154s Get:71 http://ftpmaster.internal/ubuntu questing/main ppc64el libglx0 ppc64el 1.7.0-1build1 [42.7 kB] 154s Get:72 http://ftpmaster.internal/ubuntu questing/main ppc64el libgl1 ppc64el 1.7.0-1build1 [107 kB] 154s Get:73 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqt5network5t64 ppc64el 5.15.15+dfsg-4ubuntu1 [808 kB] 155s Get:74 http://ftpmaster.internal/ubuntu questing/main ppc64el libsm6 ppc64el 2:1.2.6-1 [18.6 kB] 155s Get:75 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-icccm4 ppc64el 0.4.2-1 [11.4 kB] 155s Get:76 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-util1 ppc64el 0.4.1-1 [11.2 kB] 155s Get:77 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-image0 ppc64el 0.4.0-2build1 [12.4 kB] 155s Get:78 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-keysyms1 ppc64el 0.4.1-1 [9172 B] 155s Get:79 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-render0 ppc64el 1.17.0-2 [17.2 kB] 155s Get:80 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-render-util0 ppc64el 0.3.10-1 [11.5 kB] 155s Get:81 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-shape0 ppc64el 1.17.0-2 [6310 B] 155s Get:82 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-xinerama0 ppc64el 1.17.0-2 [5524 B] 155s Get:83 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-xinput0 ppc64el 1.17.0-2 [36.9 kB] 155s Get:84 http://ftpmaster.internal/ubuntu questing/main ppc64el libxcb-xkb1 ppc64el 1.17.0-2 [37.6 kB] 155s Get:85 http://ftpmaster.internal/ubuntu questing/main ppc64el libxkbcommon-x11-0 ppc64el 1.7.0-2 [15.3 kB] 155s Get:86 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqt5gui5t64 ppc64el 5.15.15+dfsg-4ubuntu1 [4130 kB] 212s Get:87 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqt5widgets5t64 ppc64el 5.15.15+dfsg-4ubuntu1 [2792 kB] 212s Get:88 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqt5xml5t64 ppc64el 5.15.15+dfsg-4ubuntu1 [136 kB] 212s Get:89 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqt5designer5 ppc64el 5.15.15-6build1 [2915 kB] 212s Get:90 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqt5sql5t64 ppc64el 5.15.15+dfsg-4ubuntu1 [134 kB] 212s Get:91 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqt5help5 ppc64el 5.15.15-6build1 [179 kB] 212s Get:92 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqt5printsupport5t64 ppc64el 5.15.15+dfsg-4ubuntu1 [222 kB] 212s Get:93 http://ftpmaster.internal/ubuntu questing/universe ppc64el libqt5test5t64 ppc64el 5.15.15+dfsg-4ubuntu1 [156 kB] 212s Get:94 http://ftpmaster.internal/ubuntu questing/main ppc64el libraqm0 ppc64el 0.10.2-1 [19.2 kB] 212s Get:95 http://ftpmaster.internal/ubuntu questing/main ppc64el libsharpyuv0 ppc64el 1.5.0-0.1 [22.3 kB] 212s Get:96 http://ftpmaster.internal/ubuntu questing/main ppc64el libjbig0 ppc64el 2.1-6.1ubuntu2 [35.9 kB] 212s Get:97 http://ftpmaster.internal/ubuntu questing/main ppc64el libwebp7 ppc64el 1.5.0-0.1 [315 kB] 212s Get:98 http://ftpmaster.internal/ubuntu questing/main ppc64el libtiff6 ppc64el 4.7.0-3ubuntu1 [283 kB] 212s Get:99 http://ftpmaster.internal/ubuntu questing/main ppc64el libwebpdemux2 ppc64el 1.5.0-0.1 [14.6 kB] 212s Get:100 http://ftpmaster.internal/ubuntu questing/main ppc64el libwebpmux3 ppc64el 1.5.0-0.1 [31.1 kB] 212s Get:101 http://ftpmaster.internal/ubuntu questing/main ppc64el libxt6t64 ppc64el 1:1.2.1-1.2build1 [202 kB] 212s Get:102 http://ftpmaster.internal/ubuntu questing/main ppc64el libxmu6 ppc64el 2:1.1.3-3build2 [56.8 kB] 212s Get:103 http://ftpmaster.internal/ubuntu questing/main ppc64el libxpm4 ppc64el 1:3.5.17-1build2 [49.9 kB] 212s Get:104 http://ftpmaster.internal/ubuntu questing/main ppc64el libxaw7 ppc64el 2:1.0.16-1 [230 kB] 212s Get:105 http://ftpmaster.internal/ubuntu questing/main ppc64el libxfont2 ppc64el 1:2.0.6-1build1 [116 kB] 212s Get:106 http://ftpmaster.internal/ubuntu questing/main ppc64el libxkbfile1 ppc64el 1:1.1.0-1build4 [88.9 kB] 212s Get:107 http://ftpmaster.internal/ubuntu questing/main ppc64el libxrandr2 ppc64el 2:1.5.4-1 [21.7 kB] 212s Get:108 http://ftpmaster.internal/ubuntu questing/main ppc64el libxslt1.1 ppc64el 1.1.39-0exp1ubuntu4 [191 kB] 212s Get:109 http://ftpmaster.internal/ubuntu questing-proposed/universe ppc64el python-matplotlib-data all 3.10.1+dfsg1-3 [2936 kB] 212s Get:110 http://ftpmaster.internal/ubuntu questing/universe ppc64el python-tables-data all 3.10.2-2build1 [49.7 kB] 212s Get:111 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-all ppc64el 3.13.3-1 [880 B] 212s Get:112 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-async-generator all 1.10-4 [17.5 kB] 212s Get:113 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-bottleneck ppc64el 1.4.2+ds1-2build1 [98.3 kB] 212s Get:114 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-brotli ppc64el 1.1.0-2build4 [422 kB] 212s Get:115 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-soupsieve all 2.7-1 [33.5 kB] 212s Get:116 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-bs4 all 4.13.4-1 [137 kB] 212s Get:117 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-click all 8.2.0+0.really.8.1.8-1 [80.0 kB] 212s Get:118 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-cloudpickle all 3.1.1-1 [22.4 kB] 212s Get:119 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-contourpy ppc64el 1.3.1-1build1 [218 kB] 212s Get:120 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-cpuinfo all 9.0.0+git20221119-3 [21.7 kB] 212s Get:121 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-cycler all 0.12.1-1 [9716 B] 212s Get:122 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-fsspec all 2025.3.0-1 [216 kB] 212s Get:123 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-toolz all 1.0.0-2 [45.0 kB] 212s Get:124 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-packaging all 25.0-1 [52.8 kB] 212s Get:125 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-locket all 1.0.0-2 [5872 B] 212s Get:126 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-partd all 1.4.2-1 [15.7 kB] 212s Get:127 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-dask all 2024.12.1+dfsg-2 [875 kB] 212s Get:128 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-decorator all 5.2.1-2 [28.1 kB] 212s Get:129 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-defusedxml all 0.7.1-3 [42.2 kB] 212s Get:130 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-et-xmlfile all 2.0.0-1 [79.4 kB] 212s Get:131 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-execnet all 2.1.1-1 [33.4 kB] 212s Get:132 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-platformdirs all 4.3.7-1 [16.9 kB] 212s Get:133 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-fs all 2.4.16-7 [90.8 kB] 212s Get:134 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-lxml ppc64el 5.4.0-1 [1392 kB] 212s Get:135 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-lz4 ppc64el 4.4.0+dfsg-2 [28.1 kB] 212s Get:136 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-scipy ppc64el 1.14.1-4ubuntu2 [19.4 MB] 212s Get:137 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-mpmath all 1.3.0-1 [425 kB] 212s Get:138 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-sympy all 1.13.3-5 [4229 kB] 212s Get:139 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-ufolib2 all 0.17.1+dfsg1-1 [33.5 kB] 212s Get:140 http://ftpmaster.internal/ubuntu questing/universe ppc64el unicode-data all 15.1.0-1 [8878 kB] 212s Get:141 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-fonttools ppc64el 4.55.3-2build1 [1521 kB] 212s Get:142 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-webencodings all 0.5.1-5 [11.5 kB] 212s Get:143 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-html5lib all 1.2-2 [90.6 kB] 212s Get:144 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-sortedcontainers all 2.4.0-2 [27.6 kB] 212s Get:145 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-hypothesis all 6.127.4-1 [335 kB] 212s Get:146 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-iniconfig all 1.1.1-2 [6024 B] 212s Get:147 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-kiwisolver ppc64el 1.4.7-3build1 [59.5 kB] 212s Get:148 http://ftpmaster.internal/ubuntu questing/main ppc64el libopenjp2-7 ppc64el 2.5.3-2 [248 kB] 212s Get:149 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-pil ppc64el 11.1.0-5build1 [601 kB] 212s Get:150 http://ftpmaster.internal/ubuntu questing/main ppc64el python3.13-tk ppc64el 3.13.3-1 [107 kB] 212s Get:151 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-tk ppc64el 3.13.3-1 [9854 B] 212s Get:152 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pil.imagetk ppc64el 11.1.0-5build1 [10.3 kB] 212s Get:153 http://ftpmaster.internal/ubuntu questing-proposed/universe ppc64el python3-matplotlib ppc64el 3.10.1+dfsg1-3 [18.1 MB] 212s Get:154 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-numexpr ppc64el 2.10.2-1build2 [133 kB] 212s Get:155 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-odf all 1.4.2-4 [79.0 kB] 212s Get:156 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-openpyxl all 3.1.5+dfsg-2 [152 kB] 212s Get:157 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pluggy all 1.5.0-1 [21.0 kB] 212s Get:158 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-py all 1.11.0-4 [72.7 kB] 212s Get:159 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pyqt5.sip ppc64el 12.17.0-1build1 [80.9 kB] 212s Get:160 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pyqt5 ppc64el 5.15.11+dfsg-2 [2650 kB] 212s Get:161 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pyreadstat ppc64el 1.2.8-1build1 [431 kB] 212s Get:162 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pytest all 8.3.5-1 [252 kB] 212s Get:163 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pytest-asyncio all 0.25.1-1 [17.0 kB] 212s Get:164 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pytest-forked all 1.6.0-3 [7470 B] 212s Get:165 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-werkzeug all 3.1.3-2 [169 kB] 212s Get:166 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pytest-localserver all 0.9.0.post0-1 [21.9 kB] 212s Get:167 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pytest-xdist all 3.6.1-1 [33.8 kB] 212s Get:168 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-pytestqt all 4.4.0-1 [32.4 kB] 212s Get:169 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-greenlet ppc64el 3.1.0-1build1 [168 kB] 212s Get:170 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-sqlalchemy all 2.0.38+ds1-0ubuntu2 [1215 kB] 212s Get:171 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-tables-lib ppc64el 3.10.2-2build1 [588 kB] 212s Get:172 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-tables all 3.10.2-2build1 [354 kB] 212s Get:173 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-tabulate all 0.9.0-1 [45.3 kB] 212s Get:174 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-tz all 2025.1-3 [1866 B] 212s Get:175 http://ftpmaster.internal/ubuntu questing-proposed/universe ppc64el python3-xarray all 2025.03.1-8 [831 kB] 212s Get:176 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-xlrd all 2.0.1-2 [83.1 kB] 212s Get:177 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-xlsxwriter all 3.1.9-2 [462 kB] 212s Get:178 http://ftpmaster.internal/ubuntu questing/universe ppc64el python3-zstandard ppc64el 0.23.0-3build1 [481 kB] 212s Get:179 http://ftpmaster.internal/ubuntu questing/main ppc64el tzdata-legacy all 2025b-1ubuntu1 [99.2 kB] 212s Get:180 http://ftpmaster.internal/ubuntu questing/main ppc64el x11-xkb-utils ppc64el 7.7+9 [201 kB] 212s Get:181 http://ftpmaster.internal/ubuntu questing/universe ppc64el xsel ppc64el 1.2.1-1 [20.9 kB] 212s Get:182 http://ftpmaster.internal/ubuntu questing/main ppc64el xserver-common all 2:21.1.16-1ubuntu1 [34.4 kB] 212s Get:183 http://ftpmaster.internal/ubuntu questing/universe ppc64el xvfb ppc64el 2:21.1.16-1ubuntu1 [1101 kB] 212s Get:184 http://ftpmaster.internal/ubuntu questing/universe ppc64el locales-all ppc64el 2.41-6ubuntu1 [11.2 MB] 212s Fetched 119 MB in 14s (8352 kB/s) 212s Selecting previously unselected package libtcl8.6:ppc64el. 212s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 110522 files and directories currently installed.) 212s Preparing to unpack .../000-libtcl8.6_8.6.16+dfsg-1_ppc64el.deb ... 212s Unpacking libtcl8.6:ppc64el (8.6.16+dfsg-1) ... 212s Selecting previously unselected package fonts-dejavu-mono. 212s Preparing to unpack .../001-fonts-dejavu-mono_2.37-8_all.deb ... 212s Unpacking fonts-dejavu-mono (2.37-8) ... 212s Selecting previously unselected package fonts-dejavu-core. 212s Preparing to unpack .../002-fonts-dejavu-core_2.37-8_all.deb ... 212s Unpacking fonts-dejavu-core (2.37-8) ... 212s Selecting previously unselected package fontconfig-config. 212s Preparing to unpack .../003-fontconfig-config_2.15.0-2.2ubuntu1_ppc64el.deb ... 212s Unpacking fontconfig-config (2.15.0-2.2ubuntu1) ... 212s Selecting previously unselected package libfontconfig1:ppc64el. 212s Preparing to unpack .../004-libfontconfig1_2.15.0-2.2ubuntu1_ppc64el.deb ... 212s Unpacking libfontconfig1:ppc64el (2.15.0-2.2ubuntu1) ... 212s Selecting previously unselected package libxrender1:ppc64el. 212s Preparing to unpack .../005-libxrender1_1%3a0.9.12-1_ppc64el.deb ... 212s Unpacking libxrender1:ppc64el (1:0.9.12-1) ... 212s Selecting previously unselected package libxft2:ppc64el. 212s Preparing to unpack .../006-libxft2_2.3.6-1build1_ppc64el.deb ... 212s Unpacking libxft2:ppc64el (2.3.6-1build1) ... 212s Selecting previously unselected package x11-common. 212s Preparing to unpack .../007-x11-common_1%3a7.7+23ubuntu4_all.deb ... 212s Unpacking x11-common (1:7.7+23ubuntu4) ... 212s Selecting previously unselected package libxss1:ppc64el. 212s Preparing to unpack .../008-libxss1_1%3a1.2.3-1build3_ppc64el.deb ... 212s Unpacking libxss1:ppc64el (1:1.2.3-1build3) ... 212s Selecting previously unselected package libtk8.6:ppc64el. 212s Preparing to unpack .../009-libtk8.6_8.6.16-1_ppc64el.deb ... 212s Unpacking libtk8.6:ppc64el (8.6.16-1) ... 212s Selecting previously unselected package tk8.6-blt2.5. 212s Preparing to unpack .../010-tk8.6-blt2.5_2.5.3+dfsg-8_ppc64el.deb ... 212s Unpacking tk8.6-blt2.5 (2.5.3+dfsg-8) ... 212s Selecting previously unselected package blt. 212s Preparing to unpack .../011-blt_2.5.3+dfsg-8_ppc64el.deb ... 212s Unpacking blt (2.5.3+dfsg-8) ... 212s Selecting previously unselected package fontconfig. 212s Preparing to unpack .../012-fontconfig_2.15.0-2.2ubuntu1_ppc64el.deb ... 212s Unpacking fontconfig (2.15.0-2.2ubuntu1) ... 212s Selecting previously unselected package fonts-lyx. 212s Preparing to unpack .../013-fonts-lyx_2.4.3-1_all.deb ... 212s Unpacking fonts-lyx (2.4.3-1) ... 212s Selecting previously unselected package libaec0:ppc64el. 212s Preparing to unpack .../014-libaec0_1.1.3-1_ppc64el.deb ... 212s Unpacking libaec0:ppc64el (1.1.3-1) ... 212s Selecting previously unselected package libavahi-common-data:ppc64el. 212s Preparing to unpack .../015-libavahi-common-data_0.8-16ubuntu2_ppc64el.deb ... 212s Unpacking libavahi-common-data:ppc64el (0.8-16ubuntu2) ... 212s Selecting previously unselected package libavahi-common3:ppc64el. 212s Preparing to unpack .../016-libavahi-common3_0.8-16ubuntu2_ppc64el.deb ... 212s Unpacking libavahi-common3:ppc64el (0.8-16ubuntu2) ... 212s Selecting previously unselected package libavahi-client3:ppc64el. 212s Preparing to unpack .../017-libavahi-client3_0.8-16ubuntu2_ppc64el.deb ... 212s Unpacking libavahi-client3:ppc64el (0.8-16ubuntu2) ... 212s Selecting previously unselected package libsnappy1v5:ppc64el. 212s Preparing to unpack .../018-libsnappy1v5_1.2.2-1_ppc64el.deb ... 212s Unpacking libsnappy1v5:ppc64el (1.2.2-1) ... 212s Selecting previously unselected package libblosc1:ppc64el. 212s Preparing to unpack .../019-libblosc1_1.21.5+ds-1build1_ppc64el.deb ... 212s Unpacking libblosc1:ppc64el (1.21.5+ds-1build1) ... 212s Selecting previously unselected package libblosc2-4:ppc64el. 212s Preparing to unpack .../020-libblosc2-4_2.17.1+ds-1_ppc64el.deb ... 212s Unpacking libblosc2-4:ppc64el (2.17.1+ds-1) ... 212s Selecting previously unselected package libcups2t64:ppc64el. 212s Preparing to unpack .../021-libcups2t64_2.4.12-0ubuntu1_ppc64el.deb ... 212s Unpacking libcups2t64:ppc64el (2.4.12-0ubuntu1) ... 212s Selecting previously unselected package libdeflate0:ppc64el. 212s Preparing to unpack .../022-libdeflate0_1.23-2_ppc64el.deb ... 212s Unpacking libdeflate0:ppc64el (1.23-2) ... 212s Selecting previously unselected package libdouble-conversion3:ppc64el. 212s Preparing to unpack .../023-libdouble-conversion3_3.3.1-1_ppc64el.deb ... 212s Unpacking libdouble-conversion3:ppc64el (3.3.1-1) ... 212s Selecting previously unselected package libwayland-server0:ppc64el. 212s Preparing to unpack .../024-libwayland-server0_1.23.1-3_ppc64el.deb ... 212s Unpacking libwayland-server0:ppc64el (1.23.1-3) ... 212s Selecting previously unselected package libx11-xcb1:ppc64el. 212s Preparing to unpack .../025-libx11-xcb1_2%3a1.8.12-1_ppc64el.deb ... 212s Unpacking libx11-xcb1:ppc64el (2:1.8.12-1) ... 212s Selecting previously unselected package libxcb-dri3-0:ppc64el. 212s Preparing to unpack .../026-libxcb-dri3-0_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-dri3-0:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libxcb-present0:ppc64el. 212s Preparing to unpack .../027-libxcb-present0_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-present0:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libxcb-randr0:ppc64el. 212s Preparing to unpack .../028-libxcb-randr0_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-randr0:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libxcb-sync1:ppc64el. 212s Preparing to unpack .../029-libxcb-sync1_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-sync1:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libxcb-xfixes0:ppc64el. 212s Preparing to unpack .../030-libxcb-xfixes0_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-xfixes0:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libxshmfence1:ppc64el. 212s Preparing to unpack .../031-libxshmfence1_1.3.3-1_ppc64el.deb ... 212s Unpacking libxshmfence1:ppc64el (1.3.3-1) ... 212s Selecting previously unselected package mesa-libgallium:ppc64el. 212s Preparing to unpack .../032-mesa-libgallium_25.0.3-1ubuntu2_ppc64el.deb ... 212s Unpacking mesa-libgallium:ppc64el (25.0.3-1ubuntu2) ... 212s Selecting previously unselected package libgbm1:ppc64el. 212s Preparing to unpack .../033-libgbm1_25.0.3-1ubuntu2_ppc64el.deb ... 212s Unpacking libgbm1:ppc64el (25.0.3-1ubuntu2) ... 212s Selecting previously unselected package libwayland-client0:ppc64el. 212s Preparing to unpack .../034-libwayland-client0_1.23.1-3_ppc64el.deb ... 212s Unpacking libwayland-client0:ppc64el (1.23.1-3) ... 212s Selecting previously unselected package libxcb-shm0:ppc64el. 212s Preparing to unpack .../035-libxcb-shm0_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-shm0:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libegl-mesa0:ppc64el. 212s Preparing to unpack .../036-libegl-mesa0_25.0.3-1ubuntu2_ppc64el.deb ... 212s Unpacking libegl-mesa0:ppc64el (25.0.3-1ubuntu2) ... 212s Selecting previously unselected package libfontenc1:ppc64el. 212s Preparing to unpack .../037-libfontenc1_1%3a1.1.8-1build1_ppc64el.deb ... 212s Unpacking libfontenc1:ppc64el (1:1.1.8-1build1) ... 212s Selecting previously unselected package libvulkan1:ppc64el. 212s Preparing to unpack .../038-libvulkan1_1.4.309.0-1_ppc64el.deb ... 212s Unpacking libvulkan1:ppc64el (1.4.309.0-1) ... 212s Selecting previously unselected package libgl1-mesa-dri:ppc64el. 212s Preparing to unpack .../039-libgl1-mesa-dri_25.0.3-1ubuntu2_ppc64el.deb ... 212s Unpacking libgl1-mesa-dri:ppc64el (25.0.3-1ubuntu2) ... 212s Selecting previously unselected package libxcb-glx0:ppc64el. 212s Preparing to unpack .../040-libxcb-glx0_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-glx0:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libxxf86vm1:ppc64el. 212s Preparing to unpack .../041-libxxf86vm1_1%3a1.1.4-1build4_ppc64el.deb ... 212s Unpacking libxxf86vm1:ppc64el (1:1.1.4-1build4) ... 212s Selecting previously unselected package libglx-mesa0:ppc64el. 212s Preparing to unpack .../042-libglx-mesa0_25.0.3-1ubuntu2_ppc64el.deb ... 212s Unpacking libglx-mesa0:ppc64el (25.0.3-1ubuntu2) ... 212s Selecting previously unselected package libgomp1:ppc64el. 212s Preparing to unpack .../043-libgomp1_15.1.0-2ubuntu1_ppc64el.deb ... 212s Unpacking libgomp1:ppc64el (15.1.0-2ubuntu1) ... 212s Selecting previously unselected package libgraphite2-3:ppc64el. 212s Preparing to unpack .../044-libgraphite2-3_1.3.14-2ubuntu1_ppc64el.deb ... 212s Unpacking libgraphite2-3:ppc64el (1.3.14-2ubuntu1) ... 212s Selecting previously unselected package libharfbuzz0b:ppc64el. 212s Preparing to unpack .../045-libharfbuzz0b_10.2.0-1_ppc64el.deb ... 212s Unpacking libharfbuzz0b:ppc64el (10.2.0-1) ... 212s Selecting previously unselected package libsz2:ppc64el. 212s Preparing to unpack .../046-libsz2_1.1.3-1_ppc64el.deb ... 212s Unpacking libsz2:ppc64el (1.1.3-1) ... 212s Selecting previously unselected package libhdf5-310:ppc64el. 212s Preparing to unpack .../047-libhdf5-310_1.14.5+repack-3_ppc64el.deb ... 212s Unpacking libhdf5-310:ppc64el (1.14.5+repack-3) ... 212s Selecting previously unselected package libice6:ppc64el. 212s Preparing to unpack .../048-libice6_2%3a1.1.1-1_ppc64el.deb ... 212s Unpacking libice6:ppc64el (2:1.1.1-1) ... 212s Selecting previously unselected package libimagequant0:ppc64el. 212s Preparing to unpack .../049-libimagequant0_2.18.0-1build1_ppc64el.deb ... 212s Unpacking libimagequant0:ppc64el (2.18.0-1build1) ... 212s Selecting previously unselected package libwacom-common. 212s Preparing to unpack .../050-libwacom-common_2.14.0-1_all.deb ... 212s Unpacking libwacom-common (2.14.0-1) ... 212s Selecting previously unselected package libwacom9:ppc64el. 212s Preparing to unpack .../051-libwacom9_2.14.0-1_ppc64el.deb ... 212s Unpacking libwacom9:ppc64el (2.14.0-1) ... 212s Selecting previously unselected package libinput-bin. 212s Preparing to unpack .../052-libinput-bin_1.28.1-1_ppc64el.deb ... 212s Unpacking libinput-bin (1.28.1-1) ... 212s Selecting previously unselected package libmtdev1t64:ppc64el. 212s Preparing to unpack .../053-libmtdev1t64_1.1.7-1_ppc64el.deb ... 212s Unpacking libmtdev1t64:ppc64el (1.1.7-1) ... 212s Selecting previously unselected package libinput10:ppc64el. 212s Preparing to unpack .../054-libinput10_1.28.1-1_ppc64el.deb ... 212s Unpacking libinput10:ppc64el (1.28.1-1) ... 212s Selecting previously unselected package libjpeg-turbo8:ppc64el. 212s Preparing to unpack .../055-libjpeg-turbo8_2.1.5-3ubuntu2_ppc64el.deb ... 212s Unpacking libjpeg-turbo8:ppc64el (2.1.5-3ubuntu2) ... 212s Selecting previously unselected package libjpeg8:ppc64el. 212s Preparing to unpack .../056-libjpeg8_8c-2ubuntu11_ppc64el.deb ... 212s Unpacking libjpeg8:ppc64el (8c-2ubuntu11) ... 212s Selecting previously unselected package libjs-jquery. 212s Preparing to unpack .../057-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 212s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 212s Selecting previously unselected package libjs-jquery-ui. 212s Preparing to unpack .../058-libjs-jquery-ui_1.13.2+dfsg-1_all.deb ... 212s Unpacking libjs-jquery-ui (1.13.2+dfsg-1) ... 212s Selecting previously unselected package liblbfgsb0:ppc64el. 212s Preparing to unpack .../059-liblbfgsb0_3.0+dfsg.4-1build1_ppc64el.deb ... 212s Unpacking liblbfgsb0:ppc64el (3.0+dfsg.4-1build1) ... 212s Selecting previously unselected package liblcms2-2:ppc64el. 212s Preparing to unpack .../060-liblcms2-2_2.16-2_ppc64el.deb ... 212s Unpacking liblcms2-2:ppc64el (2.16-2) ... 212s Selecting previously unselected package liblerc4:ppc64el. 212s Preparing to unpack .../061-liblerc4_4.0.0+ds-5ubuntu1_ppc64el.deb ... 212s Unpacking liblerc4:ppc64el (4.0.0+ds-5ubuntu1) ... 212s Selecting previously unselected package libmd4c0:ppc64el. 212s Preparing to unpack .../062-libmd4c0_0.5.2-2_ppc64el.deb ... 212s Unpacking libmd4c0:ppc64el (0.5.2-2) ... 212s Selecting previously unselected package libpcre2-16-0:ppc64el. 212s Preparing to unpack .../063-libpcre2-16-0_10.45-1_ppc64el.deb ... 212s Unpacking libpcre2-16-0:ppc64el (10.45-1) ... 212s Selecting previously unselected package libpixman-1-0:ppc64el. 212s Preparing to unpack .../064-libpixman-1-0_0.44.0-3_ppc64el.deb ... 212s Unpacking libpixman-1-0:ppc64el (0.44.0-3) ... 212s Selecting previously unselected package libqhull-r8.0:ppc64el. 212s Preparing to unpack .../065-libqhull-r8.0_2020.2-6build1_ppc64el.deb ... 212s Unpacking libqhull-r8.0:ppc64el (2020.2-6build1) ... 212s Selecting previously unselected package libqt5core5t64:ppc64el. 212s Preparing to unpack .../066-libqt5core5t64_5.15.15+dfsg-4ubuntu1_ppc64el.deb ... 212s Unpacking libqt5core5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Selecting previously unselected package libqt5dbus5t64:ppc64el. 212s Preparing to unpack .../067-libqt5dbus5t64_5.15.15+dfsg-4ubuntu1_ppc64el.deb ... 212s Unpacking libqt5dbus5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Selecting previously unselected package libglvnd0:ppc64el. 212s Preparing to unpack .../068-libglvnd0_1.7.0-1build1_ppc64el.deb ... 212s Unpacking libglvnd0:ppc64el (1.7.0-1build1) ... 212s Selecting previously unselected package libegl1:ppc64el. 212s Preparing to unpack .../069-libegl1_1.7.0-1build1_ppc64el.deb ... 212s Unpacking libegl1:ppc64el (1.7.0-1build1) ... 212s Selecting previously unselected package libglx0:ppc64el. 212s Preparing to unpack .../070-libglx0_1.7.0-1build1_ppc64el.deb ... 212s Unpacking libglx0:ppc64el (1.7.0-1build1) ... 212s Selecting previously unselected package libgl1:ppc64el. 212s Preparing to unpack .../071-libgl1_1.7.0-1build1_ppc64el.deb ... 212s Unpacking libgl1:ppc64el (1.7.0-1build1) ... 212s Selecting previously unselected package libqt5network5t64:ppc64el. 212s Preparing to unpack .../072-libqt5network5t64_5.15.15+dfsg-4ubuntu1_ppc64el.deb ... 212s Unpacking libqt5network5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Selecting previously unselected package libsm6:ppc64el. 212s Preparing to unpack .../073-libsm6_2%3a1.2.6-1_ppc64el.deb ... 212s Unpacking libsm6:ppc64el (2:1.2.6-1) ... 212s Selecting previously unselected package libxcb-icccm4:ppc64el. 212s Preparing to unpack .../074-libxcb-icccm4_0.4.2-1_ppc64el.deb ... 212s Unpacking libxcb-icccm4:ppc64el (0.4.2-1) ... 212s Selecting previously unselected package libxcb-util1:ppc64el. 212s Preparing to unpack .../075-libxcb-util1_0.4.1-1_ppc64el.deb ... 212s Unpacking libxcb-util1:ppc64el (0.4.1-1) ... 212s Selecting previously unselected package libxcb-image0:ppc64el. 212s Preparing to unpack .../076-libxcb-image0_0.4.0-2build1_ppc64el.deb ... 212s Unpacking libxcb-image0:ppc64el (0.4.0-2build1) ... 212s Selecting previously unselected package libxcb-keysyms1:ppc64el. 212s Preparing to unpack .../077-libxcb-keysyms1_0.4.1-1_ppc64el.deb ... 212s Unpacking libxcb-keysyms1:ppc64el (0.4.1-1) ... 212s Selecting previously unselected package libxcb-render0:ppc64el. 212s Preparing to unpack .../078-libxcb-render0_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-render0:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libxcb-render-util0:ppc64el. 212s Preparing to unpack .../079-libxcb-render-util0_0.3.10-1_ppc64el.deb ... 212s Unpacking libxcb-render-util0:ppc64el (0.3.10-1) ... 212s Selecting previously unselected package libxcb-shape0:ppc64el. 212s Preparing to unpack .../080-libxcb-shape0_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-shape0:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libxcb-xinerama0:ppc64el. 212s Preparing to unpack .../081-libxcb-xinerama0_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-xinerama0:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libxcb-xinput0:ppc64el. 212s Preparing to unpack .../082-libxcb-xinput0_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-xinput0:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libxcb-xkb1:ppc64el. 212s Preparing to unpack .../083-libxcb-xkb1_1.17.0-2_ppc64el.deb ... 212s Unpacking libxcb-xkb1:ppc64el (1.17.0-2) ... 212s Selecting previously unselected package libxkbcommon-x11-0:ppc64el. 212s Preparing to unpack .../084-libxkbcommon-x11-0_1.7.0-2_ppc64el.deb ... 212s Unpacking libxkbcommon-x11-0:ppc64el (1.7.0-2) ... 212s Selecting previously unselected package libqt5gui5t64:ppc64el. 212s Preparing to unpack .../085-libqt5gui5t64_5.15.15+dfsg-4ubuntu1_ppc64el.deb ... 212s Unpacking libqt5gui5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Selecting previously unselected package libqt5widgets5t64:ppc64el. 212s Preparing to unpack .../086-libqt5widgets5t64_5.15.15+dfsg-4ubuntu1_ppc64el.deb ... 212s Unpacking libqt5widgets5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Selecting previously unselected package libqt5xml5t64:ppc64el. 212s Preparing to unpack .../087-libqt5xml5t64_5.15.15+dfsg-4ubuntu1_ppc64el.deb ... 212s Unpacking libqt5xml5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Selecting previously unselected package libqt5designer5:ppc64el. 212s Preparing to unpack .../088-libqt5designer5_5.15.15-6build1_ppc64el.deb ... 212s Unpacking libqt5designer5:ppc64el (5.15.15-6build1) ... 212s Selecting previously unselected package libqt5sql5t64:ppc64el. 212s Preparing to unpack .../089-libqt5sql5t64_5.15.15+dfsg-4ubuntu1_ppc64el.deb ... 212s Unpacking libqt5sql5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Selecting previously unselected package libqt5help5:ppc64el. 212s Preparing to unpack .../090-libqt5help5_5.15.15-6build1_ppc64el.deb ... 212s Unpacking libqt5help5:ppc64el (5.15.15-6build1) ... 212s Selecting previously unselected package libqt5printsupport5t64:ppc64el. 212s Preparing to unpack .../091-libqt5printsupport5t64_5.15.15+dfsg-4ubuntu1_ppc64el.deb ... 212s Unpacking libqt5printsupport5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Selecting previously unselected package libqt5test5t64:ppc64el. 212s Preparing to unpack .../092-libqt5test5t64_5.15.15+dfsg-4ubuntu1_ppc64el.deb ... 212s Unpacking libqt5test5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Selecting previously unselected package libraqm0:ppc64el. 212s Preparing to unpack .../093-libraqm0_0.10.2-1_ppc64el.deb ... 212s Unpacking libraqm0:ppc64el (0.10.2-1) ... 212s Selecting previously unselected package libsharpyuv0:ppc64el. 212s Preparing to unpack .../094-libsharpyuv0_1.5.0-0.1_ppc64el.deb ... 212s Unpacking libsharpyuv0:ppc64el (1.5.0-0.1) ... 212s Selecting previously unselected package libjbig0:ppc64el. 212s Preparing to unpack .../095-libjbig0_2.1-6.1ubuntu2_ppc64el.deb ... 212s Unpacking libjbig0:ppc64el (2.1-6.1ubuntu2) ... 212s Selecting previously unselected package libwebp7:ppc64el. 212s Preparing to unpack .../096-libwebp7_1.5.0-0.1_ppc64el.deb ... 212s Unpacking libwebp7:ppc64el (1.5.0-0.1) ... 212s Selecting previously unselected package libtiff6:ppc64el. 212s Preparing to unpack .../097-libtiff6_4.7.0-3ubuntu1_ppc64el.deb ... 212s Unpacking libtiff6:ppc64el (4.7.0-3ubuntu1) ... 212s Selecting previously unselected package libwebpdemux2:ppc64el. 212s Preparing to unpack .../098-libwebpdemux2_1.5.0-0.1_ppc64el.deb ... 212s Unpacking libwebpdemux2:ppc64el (1.5.0-0.1) ... 212s Selecting previously unselected package libwebpmux3:ppc64el. 212s Preparing to unpack .../099-libwebpmux3_1.5.0-0.1_ppc64el.deb ... 212s Unpacking libwebpmux3:ppc64el (1.5.0-0.1) ... 212s Selecting previously unselected package libxt6t64:ppc64el. 212s Preparing to unpack .../100-libxt6t64_1%3a1.2.1-1.2build1_ppc64el.deb ... 212s Unpacking libxt6t64:ppc64el (1:1.2.1-1.2build1) ... 212s Selecting previously unselected package libxmu6:ppc64el. 212s Preparing to unpack .../101-libxmu6_2%3a1.1.3-3build2_ppc64el.deb ... 212s Unpacking libxmu6:ppc64el (2:1.1.3-3build2) ... 212s Selecting previously unselected package libxpm4:ppc64el. 212s Preparing to unpack .../102-libxpm4_1%3a3.5.17-1build2_ppc64el.deb ... 212s Unpacking libxpm4:ppc64el (1:3.5.17-1build2) ... 212s Selecting previously unselected package libxaw7:ppc64el. 212s Preparing to unpack .../103-libxaw7_2%3a1.0.16-1_ppc64el.deb ... 212s Unpacking libxaw7:ppc64el (2:1.0.16-1) ... 212s Selecting previously unselected package libxfont2:ppc64el. 212s Preparing to unpack .../104-libxfont2_1%3a2.0.6-1build1_ppc64el.deb ... 212s Unpacking libxfont2:ppc64el (1:2.0.6-1build1) ... 212s Selecting previously unselected package libxkbfile1:ppc64el. 212s Preparing to unpack .../105-libxkbfile1_1%3a1.1.0-1build4_ppc64el.deb ... 212s Unpacking libxkbfile1:ppc64el (1:1.1.0-1build4) ... 212s Selecting previously unselected package libxrandr2:ppc64el. 212s Preparing to unpack .../106-libxrandr2_2%3a1.5.4-1_ppc64el.deb ... 212s Unpacking libxrandr2:ppc64el (2:1.5.4-1) ... 212s Selecting previously unselected package libxslt1.1:ppc64el. 212s Preparing to unpack .../107-libxslt1.1_1.1.39-0exp1ubuntu4_ppc64el.deb ... 212s Unpacking libxslt1.1:ppc64el (1.1.39-0exp1ubuntu4) ... 212s Selecting previously unselected package python-matplotlib-data. 212s Preparing to unpack .../108-python-matplotlib-data_3.10.1+dfsg1-3_all.deb ... 212s Unpacking python-matplotlib-data (3.10.1+dfsg1-3) ... 212s Selecting previously unselected package python-tables-data. 212s Preparing to unpack .../109-python-tables-data_3.10.2-2build1_all.deb ... 212s Unpacking python-tables-data (3.10.2-2build1) ... 212s Selecting previously unselected package python3-all. 212s Preparing to unpack .../110-python3-all_3.13.3-1_ppc64el.deb ... 212s Unpacking python3-all (3.13.3-1) ... 212s Selecting previously unselected package python3-async-generator. 212s Preparing to unpack .../111-python3-async-generator_1.10-4_all.deb ... 212s Unpacking python3-async-generator (1.10-4) ... 212s Selecting previously unselected package python3-bottleneck. 212s Preparing to unpack .../112-python3-bottleneck_1.4.2+ds1-2build1_ppc64el.deb ... 212s Unpacking python3-bottleneck (1.4.2+ds1-2build1) ... 212s Selecting previously unselected package python3-brotli. 212s Preparing to unpack .../113-python3-brotli_1.1.0-2build4_ppc64el.deb ... 212s Unpacking python3-brotli (1.1.0-2build4) ... 212s Selecting previously unselected package python3-soupsieve. 212s Preparing to unpack .../114-python3-soupsieve_2.7-1_all.deb ... 212s Unpacking python3-soupsieve (2.7-1) ... 212s Selecting previously unselected package python3-bs4. 212s Preparing to unpack .../115-python3-bs4_4.13.4-1_all.deb ... 212s Unpacking python3-bs4 (4.13.4-1) ... 212s Selecting previously unselected package python3-click. 212s Preparing to unpack .../116-python3-click_8.2.0+0.really.8.1.8-1_all.deb ... 212s Unpacking python3-click (8.2.0+0.really.8.1.8-1) ... 212s Selecting previously unselected package python3-cloudpickle. 212s Preparing to unpack .../117-python3-cloudpickle_3.1.1-1_all.deb ... 212s Unpacking python3-cloudpickle (3.1.1-1) ... 212s Selecting previously unselected package python3-contourpy. 212s Preparing to unpack .../118-python3-contourpy_1.3.1-1build1_ppc64el.deb ... 212s Unpacking python3-contourpy (1.3.1-1build1) ... 212s Selecting previously unselected package python3-cpuinfo. 212s Preparing to unpack .../119-python3-cpuinfo_9.0.0+git20221119-3_all.deb ... 212s Unpacking python3-cpuinfo (9.0.0+git20221119-3) ... 212s Selecting previously unselected package python3-cycler. 212s Preparing to unpack .../120-python3-cycler_0.12.1-1_all.deb ... 212s Unpacking python3-cycler (0.12.1-1) ... 212s Selecting previously unselected package python3-fsspec. 212s Preparing to unpack .../121-python3-fsspec_2025.3.0-1_all.deb ... 212s Unpacking python3-fsspec (2025.3.0-1) ... 212s Selecting previously unselected package python3-toolz. 212s Preparing to unpack .../122-python3-toolz_1.0.0-2_all.deb ... 212s Unpacking python3-toolz (1.0.0-2) ... 212s Selecting previously unselected package python3-packaging. 212s Preparing to unpack .../123-python3-packaging_25.0-1_all.deb ... 212s Unpacking python3-packaging (25.0-1) ... 212s Selecting previously unselected package python3-locket. 212s Preparing to unpack .../124-python3-locket_1.0.0-2_all.deb ... 212s Unpacking python3-locket (1.0.0-2) ... 212s Selecting previously unselected package python3-partd. 212s Preparing to unpack .../125-python3-partd_1.4.2-1_all.deb ... 212s Unpacking python3-partd (1.4.2-1) ... 212s Selecting previously unselected package python3-dask. 212s Preparing to unpack .../126-python3-dask_2024.12.1+dfsg-2_all.deb ... 212s Unpacking python3-dask (2024.12.1+dfsg-2) ... 212s Selecting previously unselected package python3-decorator. 212s Preparing to unpack .../127-python3-decorator_5.2.1-2_all.deb ... 212s Unpacking python3-decorator (5.2.1-2) ... 212s Selecting previously unselected package python3-defusedxml. 212s Preparing to unpack .../128-python3-defusedxml_0.7.1-3_all.deb ... 212s Unpacking python3-defusedxml (0.7.1-3) ... 212s Selecting previously unselected package python3-et-xmlfile. 212s Preparing to unpack .../129-python3-et-xmlfile_2.0.0-1_all.deb ... 212s Unpacking python3-et-xmlfile (2.0.0-1) ... 212s Selecting previously unselected package python3-execnet. 212s Preparing to unpack .../130-python3-execnet_2.1.1-1_all.deb ... 212s Unpacking python3-execnet (2.1.1-1) ... 212s Selecting previously unselected package python3-platformdirs. 212s Preparing to unpack .../131-python3-platformdirs_4.3.7-1_all.deb ... 212s Unpacking python3-platformdirs (4.3.7-1) ... 212s Selecting previously unselected package python3-fs. 212s Preparing to unpack .../132-python3-fs_2.4.16-7_all.deb ... 212s Unpacking python3-fs (2.4.16-7) ... 212s Selecting previously unselected package python3-lxml:ppc64el. 212s Preparing to unpack .../133-python3-lxml_5.4.0-1_ppc64el.deb ... 212s Unpacking python3-lxml:ppc64el (5.4.0-1) ... 212s Selecting previously unselected package python3-lz4. 212s Preparing to unpack .../134-python3-lz4_4.4.0+dfsg-2_ppc64el.deb ... 212s Unpacking python3-lz4 (4.4.0+dfsg-2) ... 212s Selecting previously unselected package python3-scipy. 212s Preparing to unpack .../135-python3-scipy_1.14.1-4ubuntu2_ppc64el.deb ... 212s Unpacking python3-scipy (1.14.1-4ubuntu2) ... 212s Selecting previously unselected package python3-mpmath. 212s Preparing to unpack .../136-python3-mpmath_1.3.0-1_all.deb ... 212s Unpacking python3-mpmath (1.3.0-1) ... 212s Selecting previously unselected package python3-sympy. 212s Preparing to unpack .../137-python3-sympy_1.13.3-5_all.deb ... 212s Unpacking python3-sympy (1.13.3-5) ... 212s Selecting previously unselected package python3-ufolib2. 212s Preparing to unpack .../138-python3-ufolib2_0.17.1+dfsg1-1_all.deb ... 212s Unpacking python3-ufolib2 (0.17.1+dfsg1-1) ... 212s Selecting previously unselected package unicode-data. 212s Preparing to unpack .../139-unicode-data_15.1.0-1_all.deb ... 212s Unpacking unicode-data (15.1.0-1) ... 212s Selecting previously unselected package python3-fonttools. 212s Preparing to unpack .../140-python3-fonttools_4.55.3-2build1_ppc64el.deb ... 212s Unpacking python3-fonttools (4.55.3-2build1) ... 212s Selecting previously unselected package python3-webencodings. 212s Preparing to unpack .../141-python3-webencodings_0.5.1-5_all.deb ... 212s Unpacking python3-webencodings (0.5.1-5) ... 212s Selecting previously unselected package python3-html5lib. 212s Preparing to unpack .../142-python3-html5lib_1.2-2_all.deb ... 212s Unpacking python3-html5lib (1.2-2) ... 212s Selecting previously unselected package python3-sortedcontainers. 212s Preparing to unpack .../143-python3-sortedcontainers_2.4.0-2_all.deb ... 212s Unpacking python3-sortedcontainers (2.4.0-2) ... 212s Selecting previously unselected package python3-hypothesis. 212s Preparing to unpack .../144-python3-hypothesis_6.127.4-1_all.deb ... 212s Unpacking python3-hypothesis (6.127.4-1) ... 212s Selecting previously unselected package python3-iniconfig. 212s Preparing to unpack .../145-python3-iniconfig_1.1.1-2_all.deb ... 212s Unpacking python3-iniconfig (1.1.1-2) ... 212s Selecting previously unselected package python3-kiwisolver. 212s Preparing to unpack .../146-python3-kiwisolver_1.4.7-3build1_ppc64el.deb ... 212s Unpacking python3-kiwisolver (1.4.7-3build1) ... 212s Selecting previously unselected package libopenjp2-7:ppc64el. 212s Preparing to unpack .../147-libopenjp2-7_2.5.3-2_ppc64el.deb ... 212s Unpacking libopenjp2-7:ppc64el (2.5.3-2) ... 212s Selecting previously unselected package python3-pil:ppc64el. 212s Preparing to unpack .../148-python3-pil_11.1.0-5build1_ppc64el.deb ... 212s Unpacking python3-pil:ppc64el (11.1.0-5build1) ... 212s Selecting previously unselected package python3.13-tk. 212s Preparing to unpack .../149-python3.13-tk_3.13.3-1_ppc64el.deb ... 212s Unpacking python3.13-tk (3.13.3-1) ... 212s Selecting previously unselected package python3-tk:ppc64el. 212s Preparing to unpack .../150-python3-tk_3.13.3-1_ppc64el.deb ... 212s Unpacking python3-tk:ppc64el (3.13.3-1) ... 212s Selecting previously unselected package python3-pil.imagetk:ppc64el. 212s Preparing to unpack .../151-python3-pil.imagetk_11.1.0-5build1_ppc64el.deb ... 212s Unpacking python3-pil.imagetk:ppc64el (11.1.0-5build1) ... 212s Selecting previously unselected package python3-matplotlib. 212s Preparing to unpack .../152-python3-matplotlib_3.10.1+dfsg1-3_ppc64el.deb ... 212s Unpacking python3-matplotlib (3.10.1+dfsg1-3) ... 212s Selecting previously unselected package python3-numexpr. 212s Preparing to unpack .../153-python3-numexpr_2.10.2-1build2_ppc64el.deb ... 212s Unpacking python3-numexpr (2.10.2-1build2) ... 212s Selecting previously unselected package python3-odf. 212s Preparing to unpack .../154-python3-odf_1.4.2-4_all.deb ... 212s Unpacking python3-odf (1.4.2-4) ... 212s Selecting previously unselected package python3-openpyxl. 212s Preparing to unpack .../155-python3-openpyxl_3.1.5+dfsg-2_all.deb ... 212s Unpacking python3-openpyxl (3.1.5+dfsg-2) ... 212s Selecting previously unselected package python3-pluggy. 212s Preparing to unpack .../156-python3-pluggy_1.5.0-1_all.deb ... 212s Unpacking python3-pluggy (1.5.0-1) ... 212s Selecting previously unselected package python3-py. 212s Preparing to unpack .../157-python3-py_1.11.0-4_all.deb ... 212s Unpacking python3-py (1.11.0-4) ... 212s Selecting previously unselected package python3-pyqt5.sip. 212s Preparing to unpack .../158-python3-pyqt5.sip_12.17.0-1build1_ppc64el.deb ... 212s Unpacking python3-pyqt5.sip (12.17.0-1build1) ... 212s Selecting previously unselected package python3-pyqt5. 212s Preparing to unpack .../159-python3-pyqt5_5.15.11+dfsg-2_ppc64el.deb ... 212s Unpacking python3-pyqt5 (5.15.11+dfsg-2) ... 212s Selecting previously unselected package python3-pyreadstat. 212s Preparing to unpack .../160-python3-pyreadstat_1.2.8-1build1_ppc64el.deb ... 212s Unpacking python3-pyreadstat (1.2.8-1build1) ... 212s Selecting previously unselected package python3-pytest. 212s Preparing to unpack .../161-python3-pytest_8.3.5-1_all.deb ... 212s Unpacking python3-pytest (8.3.5-1) ... 212s Selecting previously unselected package python3-pytest-asyncio. 212s Preparing to unpack .../162-python3-pytest-asyncio_0.25.1-1_all.deb ... 212s Unpacking python3-pytest-asyncio (0.25.1-1) ... 212s Selecting previously unselected package python3-pytest-forked. 212s Preparing to unpack .../163-python3-pytest-forked_1.6.0-3_all.deb ... 212s Unpacking python3-pytest-forked (1.6.0-3) ... 212s Selecting previously unselected package python3-werkzeug. 212s Preparing to unpack .../164-python3-werkzeug_3.1.3-2_all.deb ... 212s Unpacking python3-werkzeug (3.1.3-2) ... 212s Selecting previously unselected package python3-pytest-localserver. 212s Preparing to unpack .../165-python3-pytest-localserver_0.9.0.post0-1_all.deb ... 212s Unpacking python3-pytest-localserver (0.9.0.post0-1) ... 212s Selecting previously unselected package python3-pytest-xdist. 212s Preparing to unpack .../166-python3-pytest-xdist_3.6.1-1_all.deb ... 212s Unpacking python3-pytest-xdist (3.6.1-1) ... 212s Selecting previously unselected package python3-pytestqt. 212s Preparing to unpack .../167-python3-pytestqt_4.4.0-1_all.deb ... 212s Unpacking python3-pytestqt (4.4.0-1) ... 212s Selecting previously unselected package python3-greenlet. 212s Preparing to unpack .../168-python3-greenlet_3.1.0-1build1_ppc64el.deb ... 212s Unpacking python3-greenlet (3.1.0-1build1) ... 212s Selecting previously unselected package python3-sqlalchemy. 212s Preparing to unpack .../169-python3-sqlalchemy_2.0.38+ds1-0ubuntu2_all.deb ... 212s Unpacking python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 212s Selecting previously unselected package python3-tables-lib. 212s Preparing to unpack .../170-python3-tables-lib_3.10.2-2build1_ppc64el.deb ... 212s Unpacking python3-tables-lib (3.10.2-2build1) ... 212s Selecting previously unselected package python3-tables. 212s Preparing to unpack .../171-python3-tables_3.10.2-2build1_all.deb ... 212s Unpacking python3-tables (3.10.2-2build1) ... 212s Selecting previously unselected package python3-tabulate. 212s Preparing to unpack .../172-python3-tabulate_0.9.0-1_all.deb ... 212s Unpacking python3-tabulate (0.9.0-1) ... 212s Selecting previously unselected package python3-tz. 212s Preparing to unpack .../173-python3-tz_2025.1-3_all.deb ... 212s Unpacking python3-tz (2025.1-3) ... 212s Selecting previously unselected package python3-xarray. 212s Preparing to unpack .../174-python3-xarray_2025.03.1-8_all.deb ... 212s Unpacking python3-xarray (2025.03.1-8) ... 212s Selecting previously unselected package python3-xlrd. 212s Preparing to unpack .../175-python3-xlrd_2.0.1-2_all.deb ... 212s Unpacking python3-xlrd (2.0.1-2) ... 212s Selecting previously unselected package python3-xlsxwriter. 212s Preparing to unpack .../176-python3-xlsxwriter_3.1.9-2_all.deb ... 212s Unpacking python3-xlsxwriter (3.1.9-2) ... 212s Selecting previously unselected package python3-zstandard. 212s Preparing to unpack .../177-python3-zstandard_0.23.0-3build1_ppc64el.deb ... 212s Unpacking python3-zstandard (0.23.0-3build1) ... 212s Selecting previously unselected package tzdata-legacy. 212s Preparing to unpack .../178-tzdata-legacy_2025b-1ubuntu1_all.deb ... 212s Unpacking tzdata-legacy (2025b-1ubuntu1) ... 212s Selecting previously unselected package x11-xkb-utils. 212s Preparing to unpack .../179-x11-xkb-utils_7.7+9_ppc64el.deb ... 212s Unpacking x11-xkb-utils (7.7+9) ... 212s Selecting previously unselected package xsel. 212s Preparing to unpack .../180-xsel_1.2.1-1_ppc64el.deb ... 212s Unpacking xsel (1.2.1-1) ... 212s Selecting previously unselected package xserver-common. 212s Preparing to unpack .../181-xserver-common_2%3a21.1.16-1ubuntu1_all.deb ... 212s Unpacking xserver-common (2:21.1.16-1ubuntu1) ... 212s Selecting previously unselected package xvfb. 212s Preparing to unpack .../182-xvfb_2%3a21.1.16-1ubuntu1_ppc64el.deb ... 212s Unpacking xvfb (2:21.1.16-1ubuntu1) ... 212s Selecting previously unselected package locales-all. 212s Preparing to unpack .../183-locales-all_2.41-6ubuntu1_ppc64el.deb ... 212s Unpacking locales-all (2.41-6ubuntu1) ... 212s Setting up libgraphite2-3:ppc64el (1.3.14-2ubuntu1) ... 212s Setting up xsel (1.2.1-1) ... 212s Setting up libxcb-dri3-0:ppc64el (1.17.0-2) ... 212s Setting up liblcms2-2:ppc64el (2.16-2) ... 212s Setting up python3-iniconfig (1.1.1-2) ... 212s Setting up libpixman-1-0:ppc64el (0.44.0-3) ... 212s Setting up libsharpyuv0:ppc64el (1.5.0-0.1) ... 212s Setting up libwayland-server0:ppc64el (1.23.1-3) ... 212s Setting up libx11-xcb1:ppc64el (2:1.8.12-1) ... 212s Setting up libdouble-conversion3:ppc64el (3.3.1-1) ... 212s Setting up libxcb-xfixes0:ppc64el (1.17.0-2) ... 212s Setting up liblerc4:ppc64el (4.0.0+ds-5ubuntu1) ... 212s Setting up libxpm4:ppc64el (1:3.5.17-1build2) ... 212s Setting up python3-async-generator (1.10-4) ... 212s Setting up libxcb-xinput0:ppc64el (1.17.0-2) ... 212s Setting up libxrender1:ppc64el (1:0.9.12-1) ... 212s Setting up python3-py (1.11.0-4) ... 212s Setting up python3-lz4 (4.4.0+dfsg-2) ... 212s Setting up libxcb-render0:ppc64el (1.17.0-2) ... 212s Setting up python3-defusedxml (0.7.1-3) ... 212s Setting up libglvnd0:ppc64el (1.7.0-1build1) ... 212s Setting up fonts-lyx (2.4.3-1) ... 212s Setting up libxcb-glx0:ppc64el (1.17.0-2) ... 212s Setting up python3-fsspec (2025.3.0-1) ... 212s Setting up libxcb-keysyms1:ppc64el (0.4.1-1) ... 212s Setting up libxcb-shape0:ppc64el (1.17.0-2) ... 212s Setting up x11-common (1:7.7+23ubuntu4) ... 212s Setting up libdeflate0:ppc64el (1.23-2) ... 212s Setting up python3-tabulate (0.9.0-1) ... 212s Setting up libqhull-r8.0:ppc64el (2020.2-6build1) ... 212s Setting up libxcb-render-util0:ppc64el (0.3.10-1) ... 212s Setting up python3-all (3.13.3-1) ... 212s Setting up libxcb-shm0:ppc64el (1.17.0-2) ... 212s Setting up libxcb-icccm4:ppc64el (0.4.2-1) ... 212s Setting up python3-sortedcontainers (2.4.0-2) ... 212s Setting up libgomp1:ppc64el (15.1.0-2ubuntu1) ... 212s Setting up python3-click (8.2.0+0.really.8.1.8-1) ... 212s Setting up libjbig0:ppc64el (2.1-6.1ubuntu2) ... 212s Setting up python3-webencodings (0.5.1-5) ... 212s Setting up python3-pyreadstat (1.2.8-1build1) ... 212s Setting up locales-all (2.41-6ubuntu1) ... 212s Setting up libpcre2-16-0:ppc64el (10.45-1) ... 212s Setting up libaec0:ppc64el (1.1.3-1) ... 212s Setting up python3-platformdirs (4.3.7-1) ... 212s Setting up tzdata-legacy (2025b-1ubuntu1) ... 212s Setting up python3-tz (2025.1-3) ... 212s Setting up libxcb-util1:ppc64el (0.4.1-1) ... 212s Setting up libxxf86vm1:ppc64el (1:1.1.4-1build4) ... 212s Setting up python3-cloudpickle (3.1.1-1) ... 212s Setting up libsnappy1v5:ppc64el (1.2.2-1) ... 212s Setting up libxcb-xkb1:ppc64el (1.17.0-2) ... 212s Setting up libxcb-image0:ppc64el (0.4.0-2build1) ... 212s Setting up python3-fs (2.4.16-7) ... 212s Setting up libxcb-present0:ppc64el (1.17.0-2) ... 212s Setting up unicode-data (15.1.0-1) ... 212s Setting up libqt5core5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Setting up python3-decorator (5.2.1-2) ... 212s Setting up libblosc2-4:ppc64el (2.17.1+ds-1) ... 212s Setting up libfontenc1:ppc64el (1:1.1.8-1build1) ... 212s Setting up python3-zstandard (0.23.0-3build1) ... 212s Setting up python3-packaging (25.0-1) ... 212s Setting up libxcb-xinerama0:ppc64el (1.17.0-2) ... 212s Setting up python3-xlsxwriter (3.1.9-2) ... 212s Setting up libxcb-sync1:ppc64el (1.17.0-2) ... 212s Setting up python3-werkzeug (3.1.3-2) ... 212s Setting up python3-brotli (1.1.0-2build4) ... 212s Setting up libavahi-common-data:ppc64el (0.8-16ubuntu2) ... 212s Setting up python3-greenlet (3.1.0-1build1) ... 212s Setting up python3-cycler (0.12.1-1) ... 212s Setting up libimagequant0:ppc64el (2.18.0-1build1) ... 212s Setting up libxkbcommon-x11-0:ppc64el (1.7.0-2) ... 212s Setting up fonts-dejavu-mono (2.37-8) ... 212s Setting up python3-kiwisolver (1.4.7-3build1) ... 212s Setting up python3-bottleneck (1.4.2+ds1-2build1) ... 212s Setting up libxrandr2:ppc64el (2:1.5.4-1) ... 212s Setting up libtcl8.6:ppc64el (8.6.16+dfsg-1) ... 212s Setting up fonts-dejavu-core (2.37-8) ... 212s Setting up python3-numexpr (2.10.2-1build2) ... 212s Setting up libjpeg-turbo8:ppc64el (2.1.5-3ubuntu2) ... 212s Setting up python3-cpuinfo (9.0.0+git20221119-3) ... 212s Setting up python3-html5lib (1.2-2) ... 212s Setting up libvulkan1:ppc64el (1.4.309.0-1) ... 212s Setting up python3-pluggy (1.5.0-1) ... 212s Setting up libwebp7:ppc64el (1.5.0-0.1) ... 212s Setting up python3-pyqt5.sip (12.17.0-1build1) ... 212s Setting up libmtdev1t64:ppc64el (1.1.7-1) ... 212s Setting up libxshmfence1:ppc64el (1.3.3-1) ... 212s Setting up libxcb-randr0:ppc64el (1.17.0-2) ... 212s Setting up libxslt1.1:ppc64el (1.1.39-0exp1ubuntu4) ... 212s Setting up libblosc1:ppc64el (1.21.5+ds-1build1) ... 212s Setting up python3-et-xmlfile (2.0.0-1) ... 212s Setting up libqt5sql5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Setting up libmd4c0:ppc64el (0.5.2-2) ... 212s Setting up python3-xlrd (2.0.1-2) ... 212s Setting up libopenjp2-7:ppc64el (2.5.3-2) ... 212s Setting up python3-toolz (1.0.0-2) ... 212s Setting up libharfbuzz0b:ppc64el (10.2.0-1) ... 212s Setting up python3-contourpy (1.3.1-1build1) ... 212s Setting up libxss1:ppc64el (1:1.2.3-1build3) ... 212s Setting up libxkbfile1:ppc64el (1:1.1.0-1build4) ... 212s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 212s Setting up python3-mpmath (1.3.0-1) ... 212s Setting up python3-execnet (2.1.1-1) ... 212s Setting up python-matplotlib-data (3.10.1+dfsg1-3) ... 212s Setting up libwebpmux3:ppc64el (1.5.0-0.1) ... 212s Setting up python3-locket (1.0.0-2) ... 212s Setting up libxfont2:ppc64el (1:2.0.6-1build1) ... 212s Setting up python3-soupsieve (2.7-1) ... 212s Setting up python-tables-data (3.10.2-2build1) ... 212s Setting up libsz2:ppc64el (1.1.3-1) ... 212s Setting up liblbfgsb0:ppc64el (3.0+dfsg.4-1build1) ... 212s Setting up python3-odf (1.4.2-4) ... 212s Setting up libwacom-common (2.14.0-1) ... 212s Setting up libwayland-client0:ppc64el (1.23.1-3) ... 212s Setting up libjpeg8:ppc64el (8c-2ubuntu11) ... 212s Setting up python3-partd (1.4.2-1) ... 212s Setting up python3-sympy (1.13.3-5) ... 212s Setting up libice6:ppc64el (2:1.1.1-1) ... 212s Setting up mesa-libgallium:ppc64el (25.0.3-1ubuntu2) ... 212s Setting up libqt5dbus5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Setting up python3-scipy (1.14.1-4ubuntu2) ... 212s Setting up libgbm1:ppc64el (25.0.3-1ubuntu2) ... 212s Setting up libwacom9:ppc64el (2.14.0-1) ... 212s Setting up fontconfig-config (2.15.0-2.2ubuntu1) ... 212s Setting up python3-pytest (8.3.5-1) ... 212s Setting up python3-pytest-localserver (0.9.0.post0-1) ... 212s Setting up libwebpdemux2:ppc64el (1.5.0-0.1) ... 212s Setting up python3-hypothesis (6.127.4-1) ... 212s Setting up python3-xarray (2025.03.1-8) ... 212s Setting up libgl1-mesa-dri:ppc64el (25.0.3-1ubuntu2) ... 212s Setting up libqt5network5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Setting up libavahi-common3:ppc64el (0.8-16ubuntu2) ... 212s Setting up python3-dask (2024.12.1+dfsg-2) ... 212s Setting up libqt5xml5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Setting up libqt5test5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Setting up python3-bs4 (4.13.4-1) ... 212s Setting up python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 212s Setting up libinput-bin (1.28.1-1) ... 212s Setting up python3-pytest-forked (1.6.0-3) ... 212s Setting up libegl-mesa0:ppc64el (25.0.3-1ubuntu2) ... 212s Setting up libjs-jquery-ui (1.13.2+dfsg-1) ... 212s Setting up libraqm0:ppc64el (0.10.2-1) ... 212s Setting up python3-pytest-asyncio (0.25.1-1) ... 212s Setting up libhdf5-310:ppc64el (1.14.5+repack-3) ... 212s Setting up python3-lxml:ppc64el (5.4.0-1) ... 212s Setting up libtiff6:ppc64el (4.7.0-3ubuntu1) ... 212s Setting up libegl1:ppc64el (1.7.0-1build1) ... 212s Setting up libfontconfig1:ppc64el (2.15.0-2.2ubuntu1) ... 212s Setting up libsm6:ppc64el (2:1.2.6-1) ... 212s Setting up python3-pytestqt (4.4.0-1) ... 212s Setting up libavahi-client3:ppc64el (0.8-16ubuntu2) ... 212s Setting up libinput10:ppc64el (1.28.1-1) ... 212s Setting up fontconfig (2.15.0-2.2ubuntu1) ... 212s Regenerating fonts cache... done. 212s Setting up libxft2:ppc64el (2.3.6-1build1) ... 212s Setting up libglx-mesa0:ppc64el (25.0.3-1ubuntu2) ... 212s Setting up python3-pytest-xdist (3.6.1-1) ... 212s Setting up libglx0:ppc64el (1.7.0-1build1) ... 212s Setting up python3-tables-lib (3.10.2-2build1) ... 212s Setting up libtk8.6:ppc64el (8.6.16-1) ... 212s Setting up python3-tables (3.10.2-2build1) ... 212s Setting up python3.13-tk (3.13.3-1) ... 212s Setting up python3-pil:ppc64el (11.1.0-5build1) ... 212s Setting up libgl1:ppc64el (1.7.0-1build1) ... 212s Setting up python3-openpyxl (3.1.5+dfsg-2) ... 212s Setting up libxt6t64:ppc64el (1:1.2.1-1.2build1) ... 212s Setting up libcups2t64:ppc64el (2.4.12-0ubuntu1) ... 212s Setting up tk8.6-blt2.5 (2.5.3+dfsg-8) ... 212s Setting up libxmu6:ppc64el (2:1.1.3-3build2) ... 212s Setting up blt (2.5.3+dfsg-8) ... 212s Setting up python3-tk:ppc64el (3.13.3-1) ... 212s Setting up libxaw7:ppc64el (2:1.0.16-1) ... 212s Setting up libqt5gui5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Setting up python3-pil.imagetk:ppc64el (11.1.0-5build1) ... 212s Setting up libqt5widgets5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Setting up x11-xkb-utils (7.7+9) ... 212s Setting up libqt5help5:ppc64el (5.15.15-6build1) ... 212s Setting up xserver-common (2:21.1.16-1ubuntu1) ... 212s Setting up libqt5printsupport5t64:ppc64el (5.15.15+dfsg-4ubuntu1) ... 212s Setting up libqt5designer5:ppc64el (5.15.15-6build1) ... 212s Setting up xvfb (2:21.1.16-1ubuntu1) ... 212s Setting up python3-pyqt5 (5.15.11+dfsg-2) ... 212s Setting up python3-ufolib2 (0.17.1+dfsg1-1) ... 212s Setting up python3-fonttools (4.55.3-2build1) ... 212s Setting up python3-matplotlib (3.10.1+dfsg1-3) ... 212s Processing triggers for libc-bin (2.41-6ubuntu1) ... 212s Processing triggers for man-db (2.13.1-1) ... 212s Processing triggers for udev (257.4-1ubuntu3) ... 213s autopkgtest [17:27:09]: test unittests3: [----------------------- 213s ++ dpkg --print-architecture 213s + arch=ppc64el 213s ++ py3versions -s 213s + pys=python3.13 213s + sourcetestroot=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests 213s + tomlfile=/tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 213s + echo amd64 i386 213s + grep ppc64el 213s + marker='not slow' 213s + echo ppc64el 213s + grep -E 'mips|hppa' 213s + PYTEST_WARN_IGNORE= 213s + cd /tmp/autopkgtest.ET1XN8/autopkgtest_tmp 213s + TEST_SUCCESS=true 213s + for py in $pys 213s + echo '=== python3.13 ===' 213s === python3.13 === 213s ++ python3.13 -c 'import pandas as pd; print(pd.__path__[0])' 214s + modpath=/usr/lib/python3/dist-packages/pandas 214s + for TEST_SUBSET in $modpath/tests/* 214s + echo /usr/lib/python3/dist-packages/pandas/tests/__init__.py 214s + grep -q -e __pycache__ 214s + PANDAS_CI=1 214s + LC_ALL=C.UTF-8 214s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/__init__.py 215s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 215s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 215s 215s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 215s ============================= test session starts ============================== 215s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 215s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 215s rootdir: /usr/lib/python3/dist-packages/pandas 215s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 215s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 215s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 215s collected 0 items 215s 215s =============================== warnings summary =============================== 215s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 215s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-8ywwhvhf' 215s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 215s 215s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 215s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-78rarwnr' 215s session.config.cache.set(STEPWISE_CACHE_DIR, []) 215s 215s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 215s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 215s ============================= 2 warnings in 0.16s ============================== 215s rdjoqkol test state = true 215s + test 5 == 5 215s + echo 'rdjoqkol test state = true' 215s + for TEST_SUBSET in $modpath/tests/* 215s + echo /usr/lib/python3/dist-packages/pandas/tests/__pycache__ 215s + grep -q -e __pycache__ 215s + echo 'rdjoqkol test state = true' 215s + for TEST_SUBSET in $modpath/tests/* 215s rdjoqkol test state = true 215s + echo /usr/lib/python3/dist-packages/pandas/tests/api 215s + grep -q -e __pycache__ 215s + PANDAS_CI=1 215s + LC_ALL=C.UTF-8 215s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/api 216s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 216s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 216s 216s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 216s ============================= test session starts ============================== 216s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 216s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 216s rootdir: /usr/lib/python3/dist-packages/pandas 216s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 216s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 216s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 216s collected 14 items 216s 216s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_api.py ............ 216s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_types.py .. 216s 216s =============================== warnings summary =============================== 216s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 216s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-2n17klv4' 216s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 216s 216s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 216s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-t9_vbuqc' 216s session.config.cache.set(STEPWISE_CACHE_DIR, []) 216s 216s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 216s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 216s ============================= slowest 30 durations ============================= 216s 216s (30 durations < 0.005s hidden. Use -vv to show these durations.) 216s ======================== 14 passed, 2 warnings in 0.17s ======================== 216s rdjoqkol test state = true 216s + echo 'rdjoqkol test state = true' 216s + for TEST_SUBSET in $modpath/tests/* 216s + echo /usr/lib/python3/dist-packages/pandas/tests/apply 216s + grep -q -e __pycache__ 216s + PANDAS_CI=1 216s + LC_ALL=C.UTF-8 216s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/apply 217s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 217s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 217s 217s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 218s ============================= test session starts ============================== 218s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 218s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 218s rootdir: /usr/lib/python3/dist-packages/pandas 218s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 218s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 218s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 218s collected 1243 items 218s 219s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_apply.py .s....ssss........ss.s.s...............ss..ss.s..ss...................ssssssssssssssss.........................s..............................................s.s.s.s.............................................sss.s...........s.s..s...s....... 220s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_apply_relabeling.py ..x.. 221s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_transform.py ...s.s.s................................................ss..ss..ss.....x........x........x........ 221s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_invalid_arg.py ....................................................................................................................................................................................................... 221s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_numba.py sssssssssssssssssss 222s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply.py ................................x.....x....x........................................................................................ 222s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply_relabeling.py .. 222s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_transform.py ............ 226s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_str.py ....................xxxxx...................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...........x...........x...........x...........x........ 226s 226s =============================== warnings summary =============================== 226s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 226s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-zx32yim9' 226s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 226s 226s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 226s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-1jksmzyw' 226s session.config.cache.set(STEPWISE_CACHE_DIR, []) 226s 226s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 226s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 226s ============================= slowest 30 durations ============================= 226s 0.07s call tests/apply/test_frame_apply.py::test_apply_differently_indexed 226s 0.05s call tests/apply/test_frame_apply.py::test_agg_transform[axis=1] 226s 0.05s call tests/apply/test_frame_apply.py::test_agg_transform[axis='columns'] 226s 0.03s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=1] 226s 0.03s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='columns'] 226s 0.03s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops3-names3] 226s 0.03s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops3-names3] 226s 0.03s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops1-names1] 226s 0.03s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops1-names1] 226s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops0-names0] 226s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops0-names0] 226s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops2-names2] 226s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops2-names2] 226s 0.02s call tests/apply/test_series_apply.py::test_transform[False] 226s 0.02s call tests/apply/test_series_apply.py::test_transform[compat] 226s 0.02s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis=1-pct_change] 226s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='columns'-pct_change] 226s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[apply] 226s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_namedtuple 226s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=0] 226s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[agg] 226s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='index'] 226s 0.01s call tests/apply/test_frame_apply.py::test_apply_mutating 226s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis=0] 226s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis='index'] 226s 0.01s teardown tests/apply/test_str.py::test_transform_method_name[rank] 226s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel 226s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel_partial_functions 226s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel_multi_columns_multi_methods 226s 0.01s call tests/apply/test_frame_apply.py::test_nuiscance_columns 226s =========== 1153 passed, 73 skipped, 17 xfailed, 2 warnings in 8.53s =========== 226s + echo 'rdjoqkol test state = true' 226s + for TEST_SUBSET in $modpath/tests/* 226s + echo /usr/lib/python3/dist-packages/pandas/tests/arithmetic 226s rdjoqkol test state = true 226s + grep -q -e __pycache__ 226s + PANDAS_CI=1 226s + LC_ALL=C.UTF-8 226s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arithmetic 227s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 227s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 227s 227s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 230s ============================= test session starts ============================== 230s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 230s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 230s rootdir: /usr/lib/python3/dist-packages/pandas 230s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 230s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 230s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 230s collected 19330 items 230s 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_array_ops.py .. 230s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_categorical.py .. 300s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_datetime64.py .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 302s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_interval.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 309s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_numeric.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......ss......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s..s.....s..s............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 309s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_object.py .......s........................................................................................... 311s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_period.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 316s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_timedelta64.py .................................................................................................................................................................................................................................................................s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s.....s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s.....s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s.....s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 316s 316s =============================== warnings summary =============================== 316s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 316s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-oh5acaqu' 316s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 316s 316s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 316s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-9rhmizsb' 316s session.config.cache.set(STEPWISE_CACHE_DIR, []) 316s 316s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 316s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 316s ============================= slowest 30 durations ============================= 316s 0.19s call tests/arithmetic/test_datetime64.py::TestDatetimeIndexArithmetic::test_dti_addsub_offset_arraylike[zoneinfo.ZoneInfo(key='US/Pacific')-names3-series-add] 316s 0.16s teardown tests/arithmetic/test_timedelta64.py::test_add_timestamp_to_timedelta 316s 0.13s call tests/arithmetic/test_datetime64.py::TestDatetime64Arithmetic::test_dt64arr_sub_timedeltalike_scalar[tzutc()-timedelta64_1-DataFrame] 316s 0.08s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-cls_and_kwargs27] 316s 0.08s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-False-cls_and_kwargs27] 316s 0.08s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-cls_and_kwargs27] 316s 0.07s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ns] 316s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-False-cls_and_kwargs27] 316s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-us] 316s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-True-cls_and_kwargs27] 316s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-cls_and_kwargs27] 316s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ms] 316s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-s] 316s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-CBMonthBegin] 316s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-False-cls_and_kwargs27] 316s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-False-cls_and_kwargs27] 316s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-s-5-True-cls_and_kwargs27] 316s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-True-cls_and_kwargs27] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Index-US/Central-ns-5-True-cls_and_kwargs27] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ms-5-True-cls_and_kwargs27] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-0-True-CBMonthBegin] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-False-cls_and_kwargs27] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ms-5-False-cls_and_kwargs27] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-s-5-False-cls_and_kwargs27] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-False-cls_and_kwargs27] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-True-cls_and_kwargs27] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-s-0-True-CBMonthBegin] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-CBMonthEnd] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Series-None-ms-5-True-cls_and_kwargs27] 316s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-0-True-CBMonthBegin] 316s ========== 19158 passed, 172 skipped, 2 warnings in 89.02s (0:01:29) =========== 318s + echo 'rdjoqkol test state = true' 318s rdjoqkol test state = true 318s + for TEST_SUBSET in $modpath/tests/* 318s + echo /usr/lib/python3/dist-packages/pandas/tests/arrays 318s + grep -q -e __pycache__ 318s + PANDAS_CI=1 318s + LC_ALL=C.UTF-8 318s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arrays 319s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 319s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 319s 319s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 323s ============================= test session starts ============================== 323s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 323s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 323s rootdir: /usr/lib/python3/dist-packages/pandas 323s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 323s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 323s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 323s collected 19230 items / 2 skipped 323s 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_arithmetic.py ..................... 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_astype.py ... 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_comparison.py .................................... 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_construction.py ............................. 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_function.py ........... 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_indexing.py ... 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_logical.py ................................................................................... 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_ops.py .. 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_reduction.py .............................. 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_repr.py . 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_algos.py .............. 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_analytics.py ........x..x................................................ 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_api.py ................................................................. 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_astype.py ...................... 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_constructors.py ....................................................................................................................... 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_dtypes.py .................................. 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_indexing.py ............................................................................................................................................... 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_map.py ............................. 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_missing.py .......................... 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_operators.py ...................................... 326s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_replace.py ...................... 326s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_repr.py ....................... 326s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_sorting.py .... 326s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_subclass.py ... 326s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_take.py ................ 326s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_warnings.py s 326s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_constructors.py ......................ssssssssssssss 326s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_cumulative.py ... 326s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_reductions.py ................................................................................................................................................................................................................. 326s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_arithmetic.py .............................................................. 326s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_astype.py ......... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_comparison.py .................................................................................................................. 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_concat.py ... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_construction.py ............................... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_contains.py . 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_function.py .................................................... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_repr.py ........ 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_to_numpy.py .............................. 328s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_arithmetic.py ................................................................................................................................................................................................................................................................................................................................................... 329s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_comparison.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 329s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_concat.py .................. 329s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_construction.py ............................................... 329s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_dtypes.py ......................................................................................................................... 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_function.py ............................................................................................................................. 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_indexing.py .. 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_reduction.py ............................................... 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_repr.py .......................... 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_astype.py .. 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_formats.py . 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval.py .............................................................................. 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval_pyarrow.py ssssssss 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_overlaps.py .................................................................................................................... 333s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_arithmetic.py ..............................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss............................................................................................................................................................................................................................................................................................................................................................... 333s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_function.py ..................... 333s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_indexing.py ........................................................................................................... 333s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_indexing.py ....................................... 333s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_numpy.py ....................................................................................... 333s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_astype.py .......... 333s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_constructors.py ..................... 333s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_reductions.py ... 334s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_accessor.py ............................................. 336s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_arithmetics.py ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_array.py ........................................................................... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_astype.py ........................ 337s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_combine_concat.py .......... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_constructors.py ................................. 337s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_dtype.py ........................................................ 337s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_indexing.py ................................................................................ 337s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_libsparse.py ..................................................................................... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_reductions.py ....................................................................... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_unary.py ......... 339s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/string_/test_string.py .ss.ss.ss.ss.ss.ss.ss.ss.ss.ssxssxss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.......ssss.ss.ss.ss.ss.ss.ss.ssxxssssxxssss....ssssssss....ssssssss.sssssssssssssssssssssss.ss.ss..ssss.ss...ssssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss 339s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/string_/test_string_arrow.py s.ss.ssssssssss.ssssssssssssssssssssssssssssssssss 339s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_array.py ....................................................................................... 363s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimelike.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssss....................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssss.......................................................................................................................................................................................................................................................................................................................................... 369s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimes.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 369s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_ndarray_backed.py ..... 369s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_period.py ................... 370s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_timedeltas.py ...................................................................................................................................................... 370s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_constructors.py ........ 370s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_cumulative.py ..... 370s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_reductions.py .......................... 370s 370s =============================== warnings summary =============================== 370s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 370s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-0dlz3m61' 370s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 370s 370s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 370s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-lddegy1p' 370s session.config.cache.set(STEPWISE_CACHE_DIR, []) 370s 370s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 370s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 370s ============================= slowest 30 durations ============================= 370s 0.20s teardown tests/arrays/timedeltas/test_reductions.py::TestReductions::test_mean_2d 370s 0.19s call tests/arrays/test_timedeltas.py::TestNonNano::test_mul_listlike_object[s] 370s 0.14s call tests/arrays/test_datetimelike.py::TestDatetimeArray::test_setitem_object_dtype['UTC+01:15'-QE-Index] 370s 0.12s call tests/arrays/sparse/test_accessor.py::TestSeriesAccessor::test_from_coo 370s 0.11s setup tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_bool_array_logical[integer-True] 370s 0.05s call tests/arrays/categorical/test_dtypes.py::TestCategoricalDtypes::test_codes_dtypes 370s 0.04s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[block] 370s 0.03s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[integer] 370s 0.03s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[integer] 370s 0.03s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[integer] 370s 0.03s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[block] 370s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[block] 370s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[integer] 370s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[block] 370s 0.02s call tests/arrays/integer/test_arithmetic.py::test_values_multiplying_large_series_by_NA 370s 0.01s call tests/arrays/categorical/test_constructors.py::TestCategoricalConstructors::test_constructor 370s 0.01s call tests/arrays/test_period.py::test_repr_large 370s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-labels1-csc] 370s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[QE] 370s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[ME] 370s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[D] 370s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[YE] 370s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[B] 370s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[W] 370s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-None-csc] 370s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[int64-labels1-coo] 370s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-labels1-coo] 370s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-labels1-csr] 370s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[int64-labels1-csc] 370s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[int64-labels1-csr] 370s ========= 18203 passed, 1021 skipped, 8 xfailed, 2 warnings in 51.57s ========== 371s rdjoqkol test state = true 371s + echo 'rdjoqkol test state = true' 371s + for TEST_SUBSET in $modpath/tests/* 371s + echo /usr/lib/python3/dist-packages/pandas/tests/base 371s + grep -q -e __pycache__ 371s + PANDAS_CI=1 371s + LC_ALL=C.UTF-8 371s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/base 372s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 372s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 372s 372s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 373s ============================= test session starts ============================== 373s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 373s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 373s rootdir: /usr/lib/python3/dist-packages/pandas 373s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 373s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 373s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 373s collected 1775 items 373s 373s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_constructors.py ....................... 373s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_conversion.py ................................................................................................................................................................................................................................................................................................................................... 374s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_fillna.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss 374s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_misc.py .......................................................................................................................................................................................................................................xx...xxx....................................................................s...... 375s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_transpose.py .............................................................................................................................................................................................................................. 376s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_unique.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss..................................................................................ssssssssssssssssss....ssss..........ssssssss......ss......................................................................ssssssssssss.... 377s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_value_counts.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss......................... 377s 377s =============================== warnings summary =============================== 377s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 377s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-3ypw2x19' 377s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 377s 377s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 377s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-j6jzkw_s' 377s session.config.cache.set(STEPWISE_CACHE_DIR, []) 377s 377s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 377s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 377s ============================= slowest 30 durations ============================= 377s 0.05s call tests/base/test_value_counts.py::test_value_counts_null[interval-nan] 377s 0.05s call tests/base/test_value_counts.py::test_value_counts_null[interval-None] 377s 0.03s setup tests/base/test_misc.py::test_memory_usage[datetime] 377s 0.03s call tests/base/test_value_counts.py::test_value_counts[interval] 377s 0.03s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-None] 377s 0.03s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-nan] 377s 0.02s call tests/base/test_unique.py::test_unique[datetime-tz] 377s 0.02s call tests/base/test_unique.py::test_unique[timedelta] 377s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[period-nan] 377s 0.02s call tests/base/test_value_counts.py::test_value_counts[datetime-tz] 377s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[period-None] 377s 0.02s call tests/base/test_unique.py::test_unique_null[timedelta-nan] 377s 0.02s call tests/base/test_unique.py::test_unique_null[datetime-nan] 377s 0.02s call tests/base/test_unique.py::test_unique_null[datetime-tz-nan] 377s 0.02s call tests/base/test_unique.py::test_unique_null[datetime-tz-None] 377s 0.02s call tests/base/test_unique.py::test_unique[datetime] 377s 0.02s call tests/base/test_unique.py::test_unique_null[timedelta-None] 377s 0.02s call tests/base/test_value_counts.py::test_value_counts[period] 377s 0.02s call tests/base/test_unique.py::test_unique_null[datetime-None] 377s 0.02s call tests/base/test_unique.py::test_unique_null[period-nan] 377s 0.02s call tests/base/test_value_counts.py::test_value_counts_bins[series] 377s 0.02s call tests/base/test_unique.py::test_unique[period] 377s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-nan] 377s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-None] 377s 0.02s call tests/base/test_unique.py::test_unique_null[period-None] 377s 0.02s call tests/base/test_value_counts.py::test_value_counts_bins[index] 377s 0.01s call tests/base/test_value_counts.py::test_value_counts[timedelta] 377s 0.01s teardown tests/base/test_value_counts.py::test_value_counts_object_inference_deprecated 377s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-None] 377s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-nan] 377s =========== 1581 passed, 189 skipped, 5 xfailed, 2 warnings in 4.65s =========== 377s rdjoqkol test state = true 377s + echo 'rdjoqkol test state = true' 377s + for TEST_SUBSET in $modpath/tests/* 377s + echo /usr/lib/python3/dist-packages/pandas/tests/computation 377s + grep -q -e __pycache__ 377s + PANDAS_CI=1 377s + LC_ALL=C.UTF-8 377s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/computation 378s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 378s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 378s 378s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 380s ============================= test session starts ============================== 380s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 380s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 380s rootdir: /usr/lib/python3/dist-packages/pandas 380s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 380s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 380s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 380s collected 11159 items 380s 380s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_compat.py ..... 444s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_eval.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xx..............................xx..............................xx..............................xx.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxxxx..................................................xxxxxxxxxx......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................X.........X....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................xx..xx..... 444s 444s =============================== warnings summary =============================== 444s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 444s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-1tziowsq' 444s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 444s 444s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 444s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-rq1cbfly' 444s session.config.cache.set(STEPWISE_CACHE_DIR, []) 444s 444s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 444s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 444s ============================= slowest 30 durations ============================= 444s 0.10s teardown tests/computation/test_eval.py::TestEval::test_floor_division[DataFrame-SeriesNaN-numexpr-python] 444s 0.09s call tests/computation/test_eval.py::TestEval::test_complex_cmp_ops[SeriesNaN-Series-numexpr-python-and-lt-ge] 444s 0.09s teardown tests/computation/test_eval.py::TestValidate::test_validate_bool_args[5.0] 444s 0.05s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-python] 444s 0.04s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-pandas] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-python] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-pandas] 444s 0.02s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-python] 444s 0.02s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-python] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-i-s-dt] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-i-i-dt] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-i-s-s1] 444s 0.02s call tests/computation/test_eval.py::TestOperations::test_lhs_expression_subscript 444s 0.02s call tests/computation/test_eval.py::TestOperations::test_nested_period_index_subscript_expression 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-i-i-s1] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-s-dt-i-s1] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-i-i-dt] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-i-i-s0] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-pandas-dt-dt-i-s1] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-i-s-s0] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-s-dt-dt-i] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-pandas-i-s-s-i] 444s 0.02s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-pandas] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-i-s-i] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-i-i-s0] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-pandas-i-s-s-dt] 444s 0.02s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-pandas] 444s 0.02s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-python-s-dt-i-i] 444s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-i-i-i] 444s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-pandas-&] 444s ===== 11124 passed, 33 xfailed, 2 xpassed, 2 warnings in 65.88s (0:01:05) ====== 445s rdjoqkol test state = true 445s + echo 'rdjoqkol test state = true' 445s + for TEST_SUBSET in $modpath/tests/* 445s + echo /usr/lib/python3/dist-packages/pandas/tests/config 445s + grep -q -e __pycache__ 445s + PANDAS_CI=1 445s + LC_ALL=C.UTF-8 445s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/config 446s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 446s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 446s 446s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 446s ============================= test session starts ============================== 446s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 446s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 446s rootdir: /usr/lib/python3/dist-packages/pandas 446s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 446s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 446s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 446s collected 50 items 446s 446s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_config.py ..................... 447s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_localization.py ............................. 447s 447s =============================== warnings summary =============================== 447s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 447s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-a_rhk8wh' 447s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 447s 447s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 447s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-fefp2o9j' 447s session.config.cache.set(STEPWISE_CACHE_DIR, []) 447s 447s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 447s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 447s ============================= slowest 30 durations ============================= 447s 0.02s call tests/config/test_localization.py::test_get_locales_prefix 447s 447s (29 durations < 0.005s hidden. Use -vv to show these durations.) 447s ======================== 50 passed, 2 warnings in 0.70s ======================== 447s rdjoqkol test state = true 447s + echo 'rdjoqkol test state = true' 447s + for TEST_SUBSET in $modpath/tests/* 447s + echo /usr/lib/python3/dist-packages/pandas/tests/construction 447s + grep -q -e __pycache__ 447s + PANDAS_CI=1 447s + LC_ALL=C.UTF-8 447s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/construction 447s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 447s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 447s 447s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 448s ============================= test session starts ============================== 448s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 448s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 448s rootdir: /usr/lib/python3/dist-packages/pandas 448s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 448s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 448s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 448s collected 1 item 448s 448s ../../../usr/lib/python3/dist-packages/pandas/tests/construction/test_extract_array.py . 448s 448s =============================== warnings summary =============================== 448s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 448s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-jbb0j4o6' 448s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 448s 448s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 448s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-71u3j9zb' 448s session.config.cache.set(STEPWISE_CACHE_DIR, []) 448s 448s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 448s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 448s ============================= slowest 30 durations ============================= 448s 448s (3 durations < 0.005s hidden. Use -vv to show these durations.) 448s ======================== 1 passed, 2 warnings in 0.18s ========================= 448s + echo 'rdjoqkol test state = true' 448s rdjoqkol test state = true 448s + for TEST_SUBSET in $modpath/tests/* 448s + echo /usr/lib/python3/dist-packages/pandas/tests/copy_view 448s + grep -q -e __pycache__ 448s + PANDAS_CI=1 448s + LC_ALL=C.UTF-8 448s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/copy_view 449s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 449s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 449s 449s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 450s ============================= test session starts ============================== 450s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 450s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 450s rootdir: /usr/lib/python3/dist-packages/pandas 450s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 450s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 450s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 450s collected 793 items 450s 450s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_datetimeindex.py ...... 450s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_index.py ..................... 450s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_periodindex.py .. 450s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_timedeltaindex.py .. 450s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_array.py ............. 450s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_astype.py .....ss...s..........s.. 450s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_chained_assignment_deprecation.py ............... 450s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_clip.py ...... 450s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_constructors.py ............................................................................ 450s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_core_functionalities.py ....... 451s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_functions.py .................... 451s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_indexing.py ....................................................................................s.....s........................................................................................................................................ 451s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_internals.py ..................... 452s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_interp_fillna.py ...................................................... 452s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_methods.py ........................................................................................................................................................................................................................................................ 452s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_replace.py ........................................ 452s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_setitem.py ......... 452s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_util.py .. 452s 452s =============================== warnings summary =============================== 452s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 452s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-y_3k2hsx' 452s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 452s 452s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 452s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-ctlu1byu' 452s session.config.cache.set(STEPWISE_CACHE_DIR, []) 452s 452s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 452s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 452s ============================= slowest 30 durations ============================= 452s 0.02s call tests/copy_view/test_internals.py::test_exponential_backoff 452s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[nullable-slice] 452s 0.01s teardown tests/copy_view/test_util.py::test_get_array_masked 452s 0.01s call tests/copy_view/test_indexing.py::test_midx_read_only_bool_indexer 452s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[nullable-array] 452s 0.01s call tests/copy_view/test_indexing.py::test_subset_loc_rows_columns[nullable-array-mask-mixed-block] 452s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_mask[nullable] 452s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[nullable-mask] 452s 0.01s call tests/copy_view/test_indexing.py::test_subset_iloc_rows_columns[nullable-mask-array-mixed-block] 452s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_row_indexer[nullable-iloc-slice] 452s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_column_with_loc[nullable-mixed-block] 452s 452s (19 durations < 0.005s hidden. Use -vv to show these durations.) 452s ================== 787 passed, 6 skipped, 2 warnings in 3.52s ================== 452s rdjoqkol test state = true 452s + echo 'rdjoqkol test state = true' 452s + for TEST_SUBSET in $modpath/tests/* 452s + echo /usr/lib/python3/dist-packages/pandas/tests/dtypes 452s + grep -q -e __pycache__ 452s + PANDAS_CI=1 452s + LC_ALL=C.UTF-8 452s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/dtypes 454s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 454s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 454s 454s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 456s ============================= test session starts ============================== 456s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 456s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 456s rootdir: /usr/lib/python3/dist-packages/pandas 456s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 456s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 456s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 456s collected 5628 items 456s 456s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_can_hold_element.py ........... 456s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_from_scalar.py .... 456s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_ndarray.py ....... 456s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_object_arr.py ....................................... 456s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_dict_compat.py . 456s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_downcast.py ................................... 456s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_find_common_type.py .......................................................................................... 456s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_datetimelike.py ... 456s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_dtype.py .................................................................... 456s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_maybe_box_native.py ................ 461s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_promote.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 461s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_common.py .............................................................................................................................................................................s...................................................................................................................................................................................................................................................................... 461s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_concat.py .... 462s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_dtypes.py ........................................................................................................................................................................................................................................................................................... 462s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_generic.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 463s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_inference.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss....................................................... 464s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_missing.py ..........................................................................................................xxxx............................................................................................................................................................................................................. 464s 464s =============================== warnings summary =============================== 464s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 464s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-z_fsmx2g' 464s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 464s 464s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 464s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-d6majs0v' 464s session.config.cache.set(STEPWISE_CACHE_DIR, []) 464s 464s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 464s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 464s ============================= slowest 30 durations ============================= 464s 0.15s call tests/dtypes/test_inference.py::TestInference::test_maybe_convert_objects_mixed_datetimes 464s 0.12s call tests/dtypes/test_common.py::test_is_sparse[True] 464s 0.04s teardown tests/dtypes/test_missing.py::TestIsValidNAForDtype::test_is_valid_na_for_dtype_categorical 464s 464s (27 durations < 0.005s hidden. Use -vv to show these durations.) 464s =========== 5615 passed, 9 skipped, 4 xfailed, 2 warnings in 10.79s ============ 465s rdjoqkol test state = true 465s + echo 'rdjoqkol test state = true' 465s + for TEST_SUBSET in $modpath/tests/* 465s + echo /usr/lib/python3/dist-packages/pandas/tests/extension 465s + grep -q -e __pycache__ 465s + PANDAS_CI=1 465s + LC_ALL=C.UTF-8 465s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/extension 465s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 465s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 465s 465s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 471s ============================= test session starts ============================== 471s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 471s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 471s rootdir: /usr/lib/python3/dist-packages/pandas 471s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 471s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 471s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 471s collected 16808 items / 1 skipped 471s 471s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/array_with_attr/test_array_with_attr.py . 476s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/decimal/test_decimal.py ssssssssssssssssssssssssssssssssssss....................................x.................................................................................................................................................................................................................................................................................................................................xx............................................................s............................xxxxxxxxss..............xxssxxss................................................xxx..................... 496s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/json/test_json.py ssssssssssssssssssssssssssssssssssss.................................................................................ssssssssssssssssssssssss.............................................s.......................................................s............................................ss................................................................................xx.......................................................s............xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx........xxxx........xxxxxxs.xxxxxxxxxxxxxxxxxxxxx....xxxxxxx.xx.xxxxxx...xxxxx...x...xxxxxxxxxxxx. 496s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/list/test_list.py . 498s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_categorical.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss...................................s.........................................................................................................................ss.................................................................................................xx...........................................................s............x..sxx................x.............xxxxxssssssssssssssssssssssssssssssssssss.. 498s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_common.py ............ 501s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_datetime.py ........................ssss............................................x..............................................................................................ssssssssssssssssssssssss.................................................................s......................................................................................................................................................................................xx..............................................xx...........................................................s............................................ssss......... 501s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_extension.py .............. 503s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_interval.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss.................................................................s...............................................................................................................................ss......................................................xx..............................................xx............................................................s............x. 527s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_masked.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss..................................................................................................................................................................................................................................................................................................................................................................................................x...x...x...x...x...x...x...x...x...x...x..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssssssssssssssss..ssssssssssssssssssss..........................................................................................................................................................................................................................................................................ssssssssssssssssssssss................................................................................................................................................................................ssssssssssssssssssssss......................ssssssssssssssssssssss..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxxxxxxxxxxxxxxxx..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s.s.s.s.s.s.s.s.s.s.s..................................................................................s............................................................................................x...........sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 534s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_numpy.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxx...............................................................................................................s.s........................ss.x.x...x.x.x.x.x.xxx.x.x.............x.x.....................................................x.x................ssssssssssssssssssssssssssssssssssssssssssssssss.x.x.x.x.x..xx.x..xx..xx...xxx...xxx.x...x...x.x.x..............xx..xxssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.. 538s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_period.py ..........................................ssss........ssss.....................................................................................x...x..................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssss..................................................................................................................................ss........................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxx.......................................................................................................................s.s............................................................................ssss........ssss................ 555s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_sparse.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss..ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....................................ssss................................................................................................................................................................................................................................................................................................................................................................................................xxxx........................ssss..............................................................xxxx..........................................................................................................................................xxxxxxxxxxxxxx...x.x.x.xxxxxxxxxxxxxxxss........xxxxxxxxssxxssss.x.x.x.xxxxxxxxxssxxss..........s.s.s.s.s.s...s......xxx......xx........ss..ssssss................xsxsssssssssssssss..............ssssssssssssss..............xxxx....xx.x............................x..x.x......xx.xxx......xxxxxx. 561s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_string.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss...ssssss...ssssss...ssssss...ssssss.ss.ss.ss.ss.ss.ss.ss.ss...ssssss...ssssss...ssssss...ssssss.x..ssssssss.x..ssssssss....ssssssss....ssssssss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss..ssss..ssss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss....ssssssss....ssssssss........ssssssssssssssss........ssssssssssssssss.ss.ss.ss.ss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss...ssssss...ssssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ssssssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ssssssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ssssssss.ss.ss.......................................ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.......................................ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.ss.ss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss........ssssssssssssssss........ssssssssssssssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss....ssssssss....ssssssss.ss.ss.ss.ss.ss.ss.ss.ss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss..ssss..ssss..ssss..ssss........ssssssssssssssss........ssssssssssssssss.ss.ss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss...ssssss...ssssss....ssssssss....ssssssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss..ssss..ssss.ss.ss......ssssssssssss......ssssssssssss.ss.ssssssssssssss.....ssssssssss.....ssssssssss.....ssssssssss.....ssssssssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss....ssssssss....ssssssss....ssssssss....ssssssss....ssssssss....ssssssss....ssssssss....ssssssss....ssssssss....ssssssss....ssssssss....ssssssss.ss.ss.ss.ss.ss.ss.ss.ss...ssssss...ssssss...ssssss...ssssss.ss.ss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss...ssssss...ssssss..ssss..ssssxxssssxxssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss..ssss..ssss..ssss..ssss.ss.ss.ss.ss.sssss.sssss.ss.ss.ss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.ss.ss.ss.ss 561s 561s =============================== warnings summary =============================== 561s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 561s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-2n2f2ogo' 561s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 561s 561s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 561s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-yz40rpaa' 561s session.config.cache.set(STEPWISE_CACHE_DIR, []) 561s 561s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 561s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 561s ============================= slowest 30 durations ============================= 561s 0.12s teardown tests/extension/test_string.py::test_searchsorted_with_na_raises[False-False-pyarrow_numpy] 561s 0.10s call tests/extension/json/test_json.py::TestJSONArray::test_unary_ufunc_dunder_equivalence[negative] 561s 0.09s call tests/extension/test_masked.py::TestMaskedArrays::test_setitem_loc_scalar_mixed[Int16Dtype] 561s 0.09s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index2] 561s 0.09s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt8Dtype-series-index3] 561s 0.08s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index2] 561s 0.08s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt16Dtype-series-index2] 561s 0.07s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int16Dtype-series-index2] 561s 0.07s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index3] 561s 0.07s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_array[__rpow__] 561s 0.07s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt16Dtype-series-index3] 561s 0.07s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int32Dtype-series-index2] 561s 0.07s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int16Dtype-frame-index2] 561s 0.07s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int16Dtype-series-index3] 561s 0.07s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[object-series-index2] 561s 0.07s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index3] 561s 0.07s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt8Dtype-series-index2] 561s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float32Dtype-series-index2] 561s 0.06s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index2] 561s 0.06s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_unstack[series-index2] 561s 0.06s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-series-index2] 561s 0.06s call tests/extension/test_string.py::TestStringArray::test_unstack[True-python-series-index2] 561s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt16Dtype-frame-index2] 561s 0.06s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[frame-index2] 561s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int64Dtype-frame-index3] 561s 0.06s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-frame-index2] 561s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int32Dtype-series-index3] 561s 0.06s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[object-series-index3] 561s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int64Dtype-frame-index2] 561s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int8Dtype-series-index2] 561s === 12106 passed, 4371 skipped, 332 xfailed, 2 warnings in 95.86s (0:01:35) ==== 564s + echo 'rdjoqkol test state = true' 564s + for TEST_SUBSET in $modpath/tests/* 564s + echo /usr/lib/python3/dist-packages/pandas/tests/frame 564s + grep -q -e __pycache__ 564s rdjoqkol test state = true 564s + PANDAS_CI=1 564s + LC_ALL=C.UTF-8 564s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/frame 565s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 565s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 565s 565s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 573s ============================= test session starts ============================== 573s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 573s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 573s rootdir: /usr/lib/python3/dist-packages/pandas 573s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 573s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 573s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 573s collected 11172 items / 433 deselected / 1 skipped / 10739 selected 573s 573s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_dict.py .............. 573s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_records.py ........................... 573s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_coercion.py .......x.x. 573s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_delitem.py .... 573s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get.py .... 573s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get_value.py .. 574s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_getitem.py ........................................ 576s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_indexing.py ...................................................................................................................................................................................................................................sss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 576s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_insert.py ....... 576s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_mask.py ........... 576s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_set_value.py ... 577s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_setitem.py ........................................................................................................s..........................................................................................xxx...........................x..x..x..x........ 577s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_take.py .... 580s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_where.py ............................................................................................................................................. 580s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_xs.py .............................. 580s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_add_prefix_suffix.py ... 581s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_align.py ........................................................................................................................................................................................................................................................................................................................................................................................................................ 582s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asfreq.py ........................................ 582s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asof.py ........... 582s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_assign.py ..... 582s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_astype.py .......................................................................................................................s....s........................................................................................................ss.....ssssssssss 583s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_at_time.py ...................... 583s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_between_time.py .............................. 583s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_clip.py ..................... 583s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine.py ..... 583s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine_first.py ..................................s............................... 583s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_compare.py ......................... 584s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_convert_dtypes.py ..ssss..ssss.sss.. 584s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_copy.py ..... 584s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_count.py .. 584s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_cov_corr.py .............................................................s............ 585s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_describe.py ...............................................s 585s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_diff.py .............................................. 585s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dot.py ................sss 585s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop.py ......................................................................... 585s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop_duplicates.py ..................................... 585s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_droplevel.py .. 585s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dropna.py ................... 585s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dtypes.py ........ 586s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_duplicated.py .......xxx........... 586s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_equals.py ... 586s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_explode.py ..................... 586s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_fillna.py ................................................................. 586s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_filter.py ........... 586s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_and_last.py ............. 586s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_valid_index.py ............... 586s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_get_numeric_data.py .... 588s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_head_tail.py .................................................................. 588s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_infer_objects.py . 589s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_info.py ..........................x......s...... 590s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_interpolate.py ...................................................................ssssssssss 590s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_is_homogeneous_dtype.py ....... 590s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isetitem.py ... 590s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isin.py ................. 590s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_iterrows.py . 590s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_join.py ...........s................... 590s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_map.py ......................... 590s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_matmul.py .. 591s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_nlargest.py .........................................................................................................................................................................................................................................................X.....X.....X.....X.......X..... 591s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pct_change.py ............................. 591s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pipe.py ...... 591s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pop.py ... 595s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_quantile.py ........................................................................xx..........xx..........xx..........xx.................. 597s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rank.py .........................................................................................................................ss 598s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex.py ................................................................................................................................................. 598s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex_like.py ..... 598s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename.py ......................... 598s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename_axis.py ......... 598s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reorder_levels.py ... 598s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_replace.py ...................ss.................ssss....ssss................................................................................................................................................................. 599s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reset_index.py ................................................................................................................................ 599s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_round.py ......... 599s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sample.py .......................................................... 599s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_select_dtypes.py ..................................s...... 599s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_axis.py .............. 603s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_index.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 607s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_shift.py ...................................................................................x.x.x.x.x.xxxx........ 607s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_size.py ..... 607s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_index.py ................................................................. 608s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_values.py ...................................................X...............................XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX..... 608s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swapaxes.py .... 608s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swaplevel.py . 611s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_csv.py ............................................................................. 611s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict.py ...................................................................................................... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict_of_blocks.py ... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_numpy.py .... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_period.py ...................................................................... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_records.py ................................... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_timestamp.py ...................................................................... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_transpose.py ................... 612s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_truncate.py ........................................................................................ 612s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_convert.py ........... 612s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_localize.py ......... 612s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_update.py .............. 612s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_value_counts.py ................................. 612s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_values.py ............... 612s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_alter_axes.py .. 613s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_api.py ......................ss.......... 616s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..........x................................................................................................................................ 616s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_block_internals.py ................... 619s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_constructors.py ..................................................................................................................................................................................................s.....................................................................................................................................................................................................ssssss................ssss..............................ssssss................ssss..............................ssssss................ssss..............................ssssss................ssss..............................ssssss................ssss..............................ssssss................ssss..............................ssssss................ssss..............................ssssss................ssss..............................ssssss................ssss..............................ssssss................ssss..........sss...ss..................................................................................................xxxx..xx..........xxxx..xx................................ 619s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_cumulative.py ....... 620s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_iteration.py .................... 620s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_logical_ops.py ................. 620s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_nonunique_indexes.py ................ 620s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_npfuncs.py .... 622s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_query_eval.py ..................ss..ss..ss.......................s.......................s..s......sssss.................................................s........................s..s.....sssss...............................................ss..ss......................ss.............................................................................s....ss. 628s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_reductions.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s....................................................................................................x.............x............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 628s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_repr.py ..........................................ssss................ 638s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_stack_unstack.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 638s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_subclass.py .................................................... 640s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 640s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_unary.py .................. 640s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_validate.py ............................ 640s 640s =============================== warnings summary =============================== 640s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 640s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-h2e8v348' 640s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 640s 640s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 640s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-qwbx61x_' 640s session.config.cache.set(STEPWISE_CACHE_DIR, []) 640s 640s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 640s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 640s ============================= slowest 30 durations ============================= 640s 1.97s call tests/frame/indexing/test_where.py::test_where_inplace_casting 640s 1.75s call tests/frame/methods/test_rank.py::TestRank::test_pct_max_many_rows 640s 0.87s call tests/frame/test_api.py::TestDataFrameMisc::test_inspect_getmembers 640s 0.63s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_with_dst_transitions_with_pickle 640s 0.53s call tests/frame/methods/test_info.py::test_info_verbose_with_counts_spacing[10001- # Column Non-Null Count Dtype ---- ------ -------------- ----- - 0 0 3 non-null float64- 10000 10000 3 non-null float64] 640s 0.48s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[10000] 640s 0.46s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[50000] 640s 0.46s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[100000] 640s 0.38s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorr::test_corr_scipy_method[kendall] 640s 0.33s call tests/frame/test_reductions.py::test_numeric_ea_axis_1[False-UInt8-0-median] 640s 0.27s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorrWith::test_corrwith[Float64] 640s 0.20s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[False] 640s 0.19s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_dups_cols 640s 0.19s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[0] 640s 0.19s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[index] 640s 0.18s call tests/frame/methods/test_info.py::test_info_verbose_check_header_separator_body 640s 0.18s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[False] 640s 0.15s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[True] 640s 0.15s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[index-0] 640s 0.13s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_to_string 640s 0.13s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[True] 640s 0.13s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_bytes_61_lines 640s 0.12s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[False] 640s 0.12s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[columns-1] 640s 0.11s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[True] 640s 0.11s call tests/frame/test_iteration.py::TestIteration::test_itertuples_py2_3_field_limit_namedtuple[True-1024] 640s 0.10s call tests/frame/methods/test_duplicated.py::test_duplicated_implemented_no_recursion 640s 0.09s call tests/frame/test_iteration.py::TestIteration::test_itertuples_py2_3_field_limit_namedtuple[False-1024] 640s 0.08s call tests/frame/methods/test_head_tail.py::test_head_tail_generic[datetime-DataFrame] 640s 0.08s call tests/frame/methods/test_head_tail.py::test_head_tail_generic[string-DataFrame] 640s = 10438 passed, 206 skipped, 433 deselected, 58 xfailed, 38 xpassed, 2 warnings in 75.11s (0:01:15) = 641s rdjoqkol test state = true 641s + echo 'rdjoqkol test state = true' 641s + for TEST_SUBSET in $modpath/tests/* 641s + echo /usr/lib/python3/dist-packages/pandas/tests/generic 641s + grep -q -e __pycache__ 641s + PANDAS_CI=1 641s + LC_ALL=C.UTF-8 641s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/generic 642s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 642s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 642s 642s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 642s ============================= test session starts ============================== 642s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 642s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 642s rootdir: /usr/lib/python3/dist-packages/pandas 642s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 642s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 642s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 642s collected 1249 items 642s 643s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_duplicate_labels.py ..........xx...........x.......xx.xxx................x................ 648s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_finalize.py ..........................x..................................x........x....................................................................................................................xs..s...s..s..x..x.x...x.s..s...s..s.x..x..x...x.s..s...s..s..x..x.x...x.s..s...s..s.x..x..x...x.s..s...s..s..x..x.x...x.s..s...s..s.x..x..x...x.s..s...s..s..x..x.x...x.s..s...s..s.x..x..x...x.s..s...s..s..x..x.x...x.s..s...s..s.x..x..x...x.s..s...s..s..x..x.x...x.s..s...s..s.x..x..x...x.s..s...s..s..x..x.x...x.s..s...s..s.x..x..x...x.s..s...s..s..x..x.x...x.s..s...s..s..x..x.x...x.s..s...s..s..x..x.x...x.s..s...s..s..x..x.x...x.s..s...s..s..x..x.x...x.s..s...s..s..x..x.x...x.s..s...s..s..x..x.x...x.s..s...s..s.x..x..x...x.s..s...s..s..x..x.x...x.s..s...s..s.x..x..x...x.s..s...s..s..x..x.x...x.s..s...s..s.x..x..x...x........................................................................................xxxxxxxxx..........xxxxxxxxxxxx. 648s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_frame.py ............... 649s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_generic.py ................................................................................. 649s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_label_or_level_utils.py ....................................................................... 649s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_series.py ................... 649s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py expected 649s bar a b c d e f g h 649s foo 649s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 649s bar 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s actual 649s Size: 236B 649s Dimensions: (foo: 4) 649s Coordinates: 649s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 649s Data variables: 649s a (foo) object 32B 'a' 'b' 'c' 'd' 649s b (foo) int64 32B 1 2 3 4 649s c (foo) uint8 4B 3 4 5 6 649s d (foo) float64 32B 4.0 5.0 6.0 7.0 649s e (foo) bool 4B True False True False 649s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 649s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 649s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 649s a b c d e f g h 649s foo 649s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s Xexpected 649s bar a b c d e f g h 649s foo 649s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='datetime64[ns]', name='foo', freq='D') 649s bar 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s actual 649s Size: 236B 649s Dimensions: (foo: 4) 649s Coordinates: 649s * foo (foo) datetime64[ns] 32B 2020-01-01 2020-01-02 ... 2020-01-04 649s Data variables: 649s a (foo) object 32B 'a' 'b' 'c' 'd' 649s b (foo) int64 32B 1 2 3 4 649s c (foo) uint8 4B 3 4 5 6 649s d (foo) float64 32B 4.0 5.0 6.0 7.0 649s e (foo) bool 4B True False True False 649s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 649s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 649s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 649s a b c d e f g h 649s foo 649s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='datetime64[ns]', name='foo', freq='D') 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s Xexpected 649s bar a b c ... f g h 649s foo ... 649s 2020-01-01 00:00:00-08:00 a 1 3 ... a 2013-01-01 2013-01-01 00:00:00-05:00 649s 2020-01-02 00:00:00-08:00 b 2 4 ... b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2020-01-03 00:00:00-08:00 c 3 5 ... c 2013-01-03 2013-01-03 00:00:00-05:00 649s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 649s 649s [4 rows x 8 columns] 649s DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 649s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 649s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 649s bar 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s actual 649s Size: 236B 649s Dimensions: (foo: 4) 649s Coordinates: 649s * foo (foo) object 32B 1577865600000000000 ... 1578124800000000000 649s Data variables: 649s a (foo) object 32B 'a' 'b' 'c' 'd' 649s b (foo) int64 32B 1 2 3 4 649s c (foo) uint8 4B 3 4 5 6 649s d (foo) float64 32B 4.0 5.0 6.0 7.0 649s e (foo) bool 4B True False True False 649s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 649s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 649s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 649s a b c ... f g h 649s foo ... 649s 2020-01-01 00:00:00-08:00 a 1 3 ... NaN 2013-01-01 2013-01-01 00:00:00-05:00 649s 2020-01-02 00:00:00-08:00 b 2 4 ... NaN 2013-01-02 2013-01-02 00:00:00-05:00 649s 2020-01-03 00:00:00-08:00 c 3 5 ... NaN 2013-01-03 2013-01-03 00:00:00-05:00 649s 2020-01-04 00:00:00-08:00 d 4 6 ... NaN 2013-01-04 2013-01-04 00:00:00-05:00 649s 649s [4 rows x 8 columns] 649s Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 649s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 649s dtype='object', name='foo') 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s xexpected 649s bar a b c d e f g h 649s foo 649s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s PeriodIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='period[D]', name='foo') 649s bar 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s actual 649s Size: 236B 649s Dimensions: (foo: 4) 649s Coordinates: 649s * foo (foo) object 32B 2020-01-01 2020-01-02 2020-01-03 2020-01-04 649s Data variables: 649s a (foo) object 32B 'a' 'b' 'c' 'd' 649s b (foo) int64 32B 1 2 3 4 649s c (foo) uint8 4B 3 4 5 6 649s d (foo) float64 32B 4.0 5.0 6.0 7.0 649s e (foo) bool 4B True False True False 649s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 649s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 649s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 649s a b c d e f g h 649s foo 649s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s PeriodIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='period[D]', name='foo') 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s Xexpected 649s bar a b c d e f g h 649s foo 649s 1 days a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 2 days b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 3 days c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 4 days d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', name='foo', freq='D') 649s bar 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s actual 649s Size: 236B 649s Dimensions: (foo: 4) 649s Coordinates: 649s * foo (foo) timedelta64[ns] 32B 1 days 2 days 3 days 4 days 649s Data variables: 649s a (foo) object 32B 'a' 'b' 'c' 'd' 649s b (foo) int64 32B 1 2 3 4 649s c (foo) uint8 4B 3 4 5 6 649s d (foo) float64 32B 4.0 5.0 6.0 7.0 649s e (foo) bool 4B True False True False 649s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 649s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 649s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 649s a b c d e f g h 649s foo 649s 1 days a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 2 days b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 3 days c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 4 days d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', name='foo', freq='D') 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s Xexpected 649s bar a b c d e f g h 649s foo 649s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s RangeIndex(start=0, stop=4, step=1, name='foo') 649s bar 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s actual 649s Size: 236B 649s Dimensions: (foo: 4) 649s Coordinates: 649s * foo (foo) int64 32B 0 1 2 3 649s Data variables: 649s a (foo) object 32B 'a' 'b' 'c' 'd' 649s b (foo) int64 32B 1 2 3 4 649s c (foo) uint8 4B 3 4 5 6 649s d (foo) float64 32B 4.0 5.0 6.0 7.0 649s e (foo) bool 4B True False True False 649s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 649s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 649s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 649s a b c d e f g h 649s foo 649s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s RangeIndex(start=0, stop=4, step=1, name='foo') 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s Xexpected 649s bar a b c d e f g h 649s foo 649s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s Index([0, 1, 2, 3], dtype='int8', name='foo') 649s bar 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s actual 649s Size: 208B 649s Dimensions: (foo: 4) 649s Coordinates: 649s * foo (foo) int8 4B 0 1 2 3 649s Data variables: 649s a (foo) object 32B 'a' 'b' 'c' 'd' 649s b (foo) int64 32B 1 2 3 4 649s c (foo) uint8 4B 3 4 5 6 649s d (foo) float64 32B 4.0 5.0 6.0 7.0 649s e (foo) bool 4B True False True False 649s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 649s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 649s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 649s a b c d e f g h 649s foo 649s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s Index([0, 1, 2, 3], dtype='int8', name='foo') 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s Xexpected 649s bar a b c d e f g h 649s foo 649s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s Index([0, 1, 2, 3], dtype='int16', name='foo') 649s bar 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s actual 649s Size: 212B 649s Dimensions: (foo: 4) 649s Coordinates: 649s * foo (foo) int16 8B 0 1 2 3 649s Data variables: 649s a (foo) object 32B 'a' 'b' 'c' 'd' 649s b (foo) int64 32B 1 2 3 4 649s c (foo) uint8 4B 3 4 5 6 649s d (foo) float64 32B 4.0 5.0 6.0 7.0 649s e (foo) bool 4B True False True False 649s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 649s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 649s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 649s a b c d e f g h 649s foo 649s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s Index([0, 1, 2, 3], dtype='int16', name='foo') 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s Xexpected 649s bar a b c d e f g h 649s foo 649s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s Index([0, 1, 2, 3], dtype='int32', name='foo') 649s bar 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 649s actual 649s Size: 220B 649s Dimensions: (foo: 4) 649s Coordinates: 649s * foo (foo) int32 16B 0 1 2 3 649s Data variables: 649s a (foo) object 32B 'a' 'b' 'c' 'd' 649s b (foo) int64 32B 1 2 3 4 649s c (foo) uint8 4B 3 4 5 6 649s d (foo) float64 32B 4.0 5.0 6.0 7.0 649s e (foo) bool 4B True False True False 649s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 649s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 649s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 649s a b c d e f g h 649s foo 649s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 649s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 649s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 649s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 649s Index([0, 1, 2, 3], dtype='int32', name='foo') 649s a object 649s b int64 649s c uint8 649s d float64 649s e bool 649s f category 649s g datetime64[ns] 649s h datetime64[ns, US/Eastern] 649s dtype: object 650s Xexpected 650s bar a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='int64', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) int64 32B 0 1 2 3 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='int64', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s Xexpected 650s bar a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='uint8', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 208B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) uint8 4B 0 1 2 3 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='uint8', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s Xexpected 650s bar a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='uint16', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 212B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) uint16 8B 0 1 2 3 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='uint16', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s Xexpected 650s bar a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='uint32', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 220B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) uint32 16B 0 1 2 3 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='uint32', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s Xexpected 650s bar a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='uint64', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) uint64 32B 0 1 2 3 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='uint64', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s Xexpected 650s bar a b c d e f g h 650s foo 650s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0.0, 1.0, 2.0, 3.0], dtype='float32', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 220B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) float32 16B 0.0 1.0 2.0 3.0 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0.0, 1.0, 2.0, 3.0], dtype='float32', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s Xexpected 650s bar a b c d e f g h 650s foo 650s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0.0, 1.0, 2.0, 3.0], dtype='float64', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) float64 32B 0.0 1.0 2.0 3.0 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0.0, 1.0, 2.0, 3.0], dtype='float64', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s Xexpected 650s bar a b c d e f g h 650s foo 650s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([True, False, True, False], dtype='object', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) object 32B True False True False 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s True a 1 3 4.0 True c 2013-01-01 2013-01-01 00:00:00-05:00 650s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s False b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 650s True c 3 5 6.0 True a 2013-01-03 2013-01-03 00:00:00-05:00 650s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s False d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 650s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([True, True, False, False, True, True, False, False], dtype='object', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s xexpected 650s bar a b c d e f g h 650s foo 650s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([True, False, True, False], dtype='bool', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 208B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) bool 4B True False True False 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s True a 1 3 4.0 True c 2013-01-01 2013-01-01 00:00:00-05:00 650s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s False b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 650s True c 3 5 6.0 True a 2013-01-03 2013-01-03 00:00:00-05:00 650s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s False d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 650s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([True, True, False, False, True, True, False, False], dtype='bool', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s xexpected 650s bar a b c d e f g h 650s foo 650s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex64', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) complex64 32B 0j (1+1j) (2+2j) (3+3j) 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex64', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s Xexpected 650s bar a b c d e f g h 650s foo 650s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex128', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 268B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) complex128 64B 0j (1+1j) (2+2j) (3+3j) 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex128', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s Xexpected 650s bar a b c d e f g h 650s foo 650s a a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s b b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s c c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) object 32B 'a' 'b' 'c' 'd' 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s a a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s b b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s c c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s xexpected 650s bar a b c d e f g h 650s foo 650s (0.0, 1.0] a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s (1.0, 2.0] b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s (2.0, 3.0] c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s (3.0, 4.0] d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]], dtype='interval[float64, right]', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) object 32B (0.0, 1.0] (1.0, 2.0] (2.0, 3.0] (3.0, 4.0] 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s (0.0, 1.0] a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s (1.0, 2.0] b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s (2.0, 3.0] c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s (3.0, 4.0] d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]], dtype='interval[float64, right]', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s Xsexpected 650s bar a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 1 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 0, 1, 1], dtype='int64', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) int64 32B 0 0 1 1 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 0 a 1 3 4.0 True b 2013-01-01 2013-01-01 00:00:00-05:00 650s 0 b 2 4 5.0 False a 2013-01-02 2013-01-02 00:00:00-05:00 650s 0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 1 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 1 c 3 5 6.0 True d 2013-01-03 2013-01-03 00:00:00-05:00 650s 1 d 4 6 7.0 False c 2013-01-04 2013-01-04 00:00:00-05:00 650s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 0, 0, 0, 1, 1, 1, 1], dtype='int64', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s xexpected 650s bar a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='Int64', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) object 32B 0 1 2 3 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='object', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s xexpected 650s bar a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='UInt16', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) object 32B 0 1 2 3 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0, 1, 2, 3], dtype='object', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s xexpected 650s bar a b c d e f g h 650s foo 650s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) object 32B 0.0 1.0 2.0 3.0 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s xexpected 650s bar a b c d e f g h 650s foo 650s False a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s True b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([False, True, True, True], dtype='boolean', name='foo') 650s bar 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 650s actual 650s Size: 236B 650s Dimensions: (foo: 4) 650s Coordinates: 650s * foo (foo) object 32B False True True True 650s Data variables: 650s a (foo) object 32B 'a' 'b' 'c' 'd' 650s b (foo) int64 32B 1 2 3 4 650s c (foo) uint8 4B 3 4 5 6 650s d (foo) float64 32B 4.0 5.0 6.0 7.0 650s e (foo) bool 4B True False True False 650s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 650s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 650s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 650s a b c d e f g h 650s foo 650s False a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 650s True b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 650s True b 2 4 5.0 False c 2013-01-02 2013-01-02 00:00:00-05:00 650s True b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 650s True c 3 5 6.0 True b 2013-01-03 2013-01-03 00:00:00-05:00 650s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 650s True c 3 5 6.0 True d 2013-01-03 2013-01-03 00:00:00-05:00 650s True d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 650s True d 4 6 7.0 False c 2013-01-04 2013-01-04 00:00:00-05:00 650s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 650s Index([False, True, True, True, True, True, True, True, True, True], dtype='object', name='foo') 650s a object 650s b int64 650s c uint8 650s d float64 650s e bool 650s f category 650s g datetime64[ns] 650s h datetime64[ns, US/Eastern] 650s dtype: object 651s xexpected 651s bar a b c d e f g h 651s foo 651s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 651s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 651s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 651s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 651s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 651s bar 651s a object 651s b int64 651s c uint8 651s d float64 651s e bool 651s f category 651s g datetime64[ns] 651s h datetime64[ns, US/Eastern] 651s dtype: object 651s actual 651s Size: 236B 651s Dimensions: (foo: 4) 651s Coordinates: 651s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 651s Data variables: 651s a (foo) object 32B 'a' 'b' 'c' 'd' 651s b (foo) int64 32B 1 2 3 4 651s c (foo) uint8 4B 3 4 5 6 651s d (foo) float64 32B 4.0 5.0 6.0 7.0 651s e (foo) bool 4B True False True False 651s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 651s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 651s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 651s a b c d e f g h 651s foo 651s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 651s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 651s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 651s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 651s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 651s a object 651s b int64 651s c uint8 651s d float64 651s e bool 651s f category 651s g datetime64[ns] 651s h datetime64[ns, US/Eastern] 651s dtype: object 651s x................................. 651s 651s =============================== warnings summary =============================== 651s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 651s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-2qsmpuez' 651s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 651s 651s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 651s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-45gtr5zb' 651s session.config.cache.set(STEPWISE_CACHE_DIR, []) 651s 651s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 651s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 651s ============================= slowest 30 durations ============================= 651s 0.43s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string] 651s 0.05s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 651s 0.05s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[interval] 651s 0.05s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 651s 0.04s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 651s 0.04s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[period] 651s 0.04s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 651s 0.04s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 651s 0.04s call tests/generic/test_generic.py::TestGeneric::test_truncate_out_of_bounds[DataFrame] 651s 0.04s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[timedelta] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[complex128] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint16] 651s 0.03s call tests/generic/test_generic.py::TestGeneric::test_truncate_out_of_bounds[Series] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[float32] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[complex64] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[float64] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int32] 651s 0.03s teardown tests/generic/test_to_xarray.py::TestSeriesToXArray::test_to_xarray_with_multiindex 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint32] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int8] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[range] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int64] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint64] 651s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint8] 651s ==== 978 passed, 105 skipped, 148 xfailed, 18 xpassed, 2 warnings in 8.92s ===== 651s rdjoqkol test state = true 651s + echo 'rdjoqkol test state = true' 651s + for TEST_SUBSET in $modpath/tests/* 651s + echo /usr/lib/python3/dist-packages/pandas/tests/groupby 651s + grep -q -e __pycache__ 651s + PANDAS_CI=1 651s + LC_ALL=C.UTF-8 651s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/groupby 652s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 652s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 652s 652s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 657s ============================= test session starts ============================== 657s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 657s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 657s rootdir: /usr/lib/python3/dist-packages/pandas 657s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 657s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 657s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 657s collected 29434 items / 1832 deselected / 1 skipped / 27602 selected 657s 659s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_aggregate.py ...............................................................................................................................................................................................................................................................................................................................................x..x.......................................................................x....... 659s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_cython.py ........................................................................................................................................................................ 660s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 660s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_other.py ........................................ 660s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_corrwith.py . 660s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_describe.py ......................... 660s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_groupby_shift_diff.py ............................................... 660s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_is_monotonic.py ...... 661s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_nlargest_nsmallest.py ........................................... 661s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_nth.py .................................................................................................................................................................................................................................... 663s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_quantile.py ..................................................................................................x....x.......................................................................................................................................................................................................................... 667s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_rank.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 667s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_sample.py .............. 670s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_size.py .......x....x....x....x....x....x....x....x...............ss 670s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_skew.py . 672s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_value_counts.py ...........X......XXX...XXX.........XXX...XXX........................................ss.ss.ss.ss.ss.ss....XX..........................XXXXXXXXXXXXXXXX........XXXXXXXX...................................... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_all_methods.py ......................................xx..............................................................................................ss..........ss..............ss...... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_api.py ......s..s..............................s..s.......................... 673s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_apply.py .................................................................................................................................... 673s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_apply_mutate.py ..... 673s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_bin_groupby.py ...... 690s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_categorical.py .................................................................................................................................x......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ss.ss.ss.ssxxxxxx.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ssxxxxxx.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ssxxxxxx.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ssxxxxxx.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s........s........s........s........s........s........s........s...ss.sssss.ss.sssss.ss.sssss.ss.sssss.ss.sssss.ss.sssss.ss.sssss.ss.sssss...................ss.ss.ss.ss.ss.ss.................sxsx................................................................................sxsx................................................................................sxsx................................................................................sxsx.......................................x................................ 690s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_counting.py .................................ssss 690s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_cumulative.py ..................................................... 691s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_filters.py ............................ 701s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby.py ......................................s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s...................s................................................................................................................... 727s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby_dropna.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxx.................................................. 727s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby_subclass.py .....s................................................................. 728s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_grouping.py ....................................................................................... 728s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_index_as_string.py .................. 728s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_indexing.py ............................................................................................................................................................................ 729s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_libgroupby.py ........................... 729s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_missing.py ......................... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numeric_only.py ..................xxx......ssssss..............................xxx.................................................................................................................................................................................................................................................................................................................................................................................. 730s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_pipe.py .. 762s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_raises.py ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 764s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_reductions.py ...............................................................................................................................................................................................................................................................................................................ss........................................................................................................................................................ 765s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 765s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 780s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_transform.py ....................x.........................................................................................................................x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x....................................................................................x....................x............................................................................................................................................................................................................ 780s 780s =============================== warnings summary =============================== 780s tests/groupby/test_categorical.py::test_basic 780s /usr/lib/python3/dist-packages/numpy/_core/fromnumeric.py:84: FutureWarning: The behavior of DataFrame.sum with axis=None is deprecated, in a future version this will reduce over both axes and return a scalar. To retain the old behavior, pass axis=0 (or do not pass axis) 780s return reduction(axis=axis, out=out, **passkwargs) 780s 780s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 780s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-z7qoy14n' 780s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 780s 780s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 780s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-9l34dc80' 780s session.config.cache.set(STEPWISE_CACHE_DIR, []) 780s 780s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 780s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 780s ============================= slowest 30 durations ============================= 780s 0.39s call tests/groupby/test_reductions.py::test_ops_general[sem-scipy_sem] 780s 0.22s call tests/groupby/test_raises.py::test_groupby_raises_category_on_category[by2-True-cumsum-False-agg] 780s 0.21s teardown tests/groupby/transform/test_transform.py::test_idxmin_idxmax_transform_args[False-False-idxmin] 780s 0.14s call tests/groupby/test_groupby.py::test_empty_groupby[False-skew-agg-float-keys1-C] 780s 0.11s call tests/groupby/test_categorical.py::test_basic 780s 0.09s call tests/groupby/test_counting.py::test_count 780s 0.08s call tests/groupby/test_counting.py::TestCounting::test_ngroup_cumcount_pair 780s 0.08s call tests/groupby/test_timegrouper.py::TestGroupBy::test_timegrouper_with_reg_groups 780s 0.07s call tests/groupby/test_groupby_subclass.py::test_groupby_preserves_subclass[corrwith-obj0] 780s 0.06s call tests/groupby/test_categorical.py::test_datetime 780s 0.06s call tests/groupby/methods/test_describe.py::test_frame_describe_multikey 780s 0.05s call tests/groupby/test_apply.py::test_apply_concat_preserve_names 780s 0.05s call tests/groupby/test_groupby.py::test_groupby_multiindex_not_lexsorted 780s 0.04s call tests/groupby/transform/test_transform.py::test_cython_transform_series[cumsum-args1-] 780s 0.04s call tests/groupby/transform/test_transform.py::test_as_index_no_change[corrwith-keys1] 780s 0.04s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-True-True-multi] 780s 0.04s call tests/groupby/test_apply.py::test_apply_corner_cases 780s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-True-multi] 780s 0.03s call tests/groupby/test_categorical.py::test_observed[False] 780s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-False-False-multi] 780s 0.03s call tests/groupby/test_categorical.py::test_describe_categorical_columns 780s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-False-True-multi] 780s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-False-single] 780s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-True-multi] 780s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-False-multi] 780s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-False-multi] 780s 0.03s call tests/groupby/transform/test_transform.py::test_cython_transform_series[shift-args2-] 780s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-True-single] 780s 0.03s call tests/groupby/transform/test_transform.py::test_cython_transform_series[shift-args3-] 780s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-True-False-multi] 780s = 26564 passed, 910 skipped, 1832 deselected, 90 xfailed, 39 xpassed, 3 warnings in 127.44s (0:02:07) = 781s rdjoqkol test state = true 781s + echo 'rdjoqkol test state = true' 781s + for TEST_SUBSET in $modpath/tests/* 781s + echo /usr/lib/python3/dist-packages/pandas/tests/indexes 781s + grep -q -e __pycache__ 781s + PANDAS_CI=1 781s + LC_ALL=C.UTF-8 781s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/indexes 782s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 782s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 782s 782s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 792s ============================= test session starts ============================== 792s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 792s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 792s rootdir: /usr/lib/python3/dist-packages/pandas 792s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 792s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 792s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 792s collected 17010 items / 4 deselected / 17006 selected 792s 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_constructors.py .......s.. 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_formats.py .............. 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_indexing.py ............ 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_pickle.py . 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_reshape.py ..............s.... 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_setops.py ............................................................ 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_where.py . 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_append.py ....... 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_astype.py ........... 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_category.py ......................................... 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_constructors.py ..... 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_equals.py ......ss 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_fillna.py ... 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_formats.py .. 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_indexing.py ................................. 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_map.py ..................... 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_reindex.py ....... 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_setops.py .. 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_drop_duplicates.py ................................................................................................................ 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_equals.py ..................... 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_indexing.py ................ 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_is_monotonic.py . 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_nat.py ...................... 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_sort_values.py ................................................................................... 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_value_counts.py ............................................ 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_asof.py .. 794s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_astype.py ................................. 794s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_delete.py ....................... 794s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_factorize.py .................................................................................... 794s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_fillna.py .. 794s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_insert.py ............................................................................................................................................................................................. 794s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_isocalendar.py .. 794s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_map.py ..... 794s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_normalize.py ......... 795s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_repeat.py .................................................................................................................................................................................................................................................................................................................................................... 795s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_resolution.py .................................................................................................................................................................................... 796s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_round.py ...................................................................................................................................................................................................................... 796s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_shift.py ........................................................................................................................................ 797s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_snap.py ........................ 797s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_frame.py .. 797s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_julian_date.py ..... 797s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_period.py ........................................... 797s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_pydatetime.py .. 797s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_series.py . 797s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_tz_convert.py .................................... 797s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_tz_localize.py ............................................................................................................................................................ 797s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_unique.py ........................ 798s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_arithmetic.py .....................x 798s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_constructors.py ..................................................................................................................................................................................................................x...x.................................... 801s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_date_range.py .................................................................................................................................................................................................................................................................................................................................................. 801s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_datetime.py .................. 801s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_formats.py ........................................ 801s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_freq_attr.py .......................... 802s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................... 802s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_iter.py ............ 802s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_join.py ...................... 802s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_npfuncs.py . 802s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_ops.py ................ 803s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_partial_slicing.py .................................. 803s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_pickle.py ...... 803s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_reindex.py .. 811s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_scalar_compat.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 811s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_setops.py ................................................................................................................................ 811s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_timezones.py ........................................ 812s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_astype.py ....................................x........................................................................................................................... 813s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_constructors.py ............................................................................................................................................................................................................................................................................ssssssss.......................................s.................s.....s.....s.....s....................................ssssssss.......................................s.................s.....s.....s.....s.................................s 813s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_equals.py .... 813s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_formats.py ........... 813s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_indexing.py ............................................................................................................................................................................................................................................................................................ 814s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval.py .......x....x....x....x.................................................................................................................................................................................................................................. 815s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval_range.py ........................................................................................................................................................ 816s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval_tree.py .................................................................................................................................................................................................................... 816s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_join.py ... 816s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_pickle.py ... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_setops.py ................................................................................. 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_analytics.py ...................................... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_astype.py ... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_compat.py ...... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_constructors.py ..................................................................................s................. 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_conversion.py ...... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_copy.py .......... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_drop.py ............. 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_duplicates.py .................................................. 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_equivalence.py .............. 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_formats.py .............. 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_get_level_values.py ....... 818s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_get_set.py ................... 818s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_indexing.py ........................................................................................................................................... 818s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_integrity.py ................ 818s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_isin.py .............. 819s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_join.py ....................................................... 819s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_lexsort.py .. 819s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_missing.py ...x.. 819s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_monotonic.py ........... 819s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_names.py ............................... 819s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_partial_indexing.py ..... 819s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_pickle.py . 819s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_reindex.py ............ 819s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_reshape.py ........... 820s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_setops.py ............................................................................................................................................................................................................sss................................................................... 821s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_sorting.py .......................... 821s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_take.py ... 821s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_astype.py ................... 821s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_indexing.py ..............................................................................................................................................ss.......................................... 821s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_join.py ........... 821s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_numeric.py ................................................................................................ 821s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_setops.py .................... 821s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/object/test_astype.py .. 822s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/object/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.ss. 822s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_asfreq.py ............... 822s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_astype.py ............. 822s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_factorize.py .. 822s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_fillna.py . 822s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_insert.py ... 822s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_is_full.py . 822s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_repeat.py ...... 822s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_shift.py ...... 822s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_to_timestamp.py ........ 822s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_constructors.py .................................................................................................. 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_formats.py ................... 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_freq_attr.py . 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_indexing.py ......................................................................... 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_join.py ........... 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_monotonic.py .. 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_partial_slicing.py .............. 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_period.py .................................................................................................................................... 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_period_range.py ........................... 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_pickle.py .... 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_resolution.py ......... 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_scalar_compat.py ... 823s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_searchsorted.py ........ 824s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_setops.py .............. 824s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_tools.py ............ 824s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_constructors.py ............................. 824s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_indexing.py ............... 824s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_join.py .......... 824s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_range.py ................................................................................. 824s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_setops.py ................................................................... 825s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_any_index.py ......................................................................................................................s......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 828s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_base.py .........................................................................................................................................................................x.............................................................................ssss....ss..........ss......ss.................................................................................................................................ssss...........................................................................................................................................................................................................................................s.......................................................................................................s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s 829s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_common.py ...........................................................................................................................................................................................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.........................................................................................................................sssssssss...s....ss..........................xs.....................sss................................................sss....................................................................................s................s...............................................................................................................................................................................................................................................................................XX........................................... 829s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_datetimelike.py ........................................ 830s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_engines.py ......................................... 830s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_frozen.py .......... 830s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_index_new.py ............................................xxxxssss................................................................................................................ 831s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_indexing.py ......................................................ss...............................s.................................................................................................................................................................................................................................................................................................s........................ 832s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_numpy_compat.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ss..................... 834s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_old_base.py s...s...................sss.............................ssssssssss.s..........ss.................s.............s.....s..............s..sss..........................................................s.......................................................................ssssssss..s..sssssssss..s..sssssssss..s..sssssssss..s..sssssssss..s..s......................s..............................................s................s..............................s........................ssssssss....s.s...s.....s........sssssssss...s....s...sss...................................................................................................................ss......................ssssss.........................................................................................................................................................................s......................................................................................................................................................................................s...s...........s...s...........................................................................................s...s... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_setops.py ...........................................................................................................................................x........................................................................................................................................................................................................................................................................................................................................................................................................................X..................................................................x....................................................................................................X.........X...............................................................................................................X..........................................................................................................................................................................................................................................................................................................................................................s...........................................................................................................................ss..s.s...s...s.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssss....ss..........ss......ss..................................................................................................................................................................................................................................................................ssss....ss..........ss......ss................................................................................................................................................................................................................................................................s...........................................................................................................................................................................................ss 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_subclass.py . 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_astype.py ............... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_factorize.py .. 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_fillna.py . 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_insert.py ............... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_repeat.py . 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_shift.py ...... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_arithmetic.py ... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_constructors.py ..................... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_delete.py ... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_formats.py ..... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_freq_attr.py ........... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_indexing.py .................................... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_join.py ....... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_ops.py .......... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_pickle.py . 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_scalar_compat.py ........ 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_searchsorted.py ........ 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_setops.py ................................ 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_timedelta.py ... 841s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_timedelta_range.py ............................ 841s 841s =============================== warnings summary =============================== 841s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 841s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-76bx7x61' 841s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 841s 841s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 841s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-_mnyr6om' 841s session.config.cache.set(STEPWISE_CACHE_DIR, []) 841s 841s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 841s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 841s ============================= slowest 30 durations ============================= 841s 0.26s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[ms] 841s 0.22s call tests/indexes/period/test_indexing.py::TestGetItem::test_getitem_seconds 841s 0.21s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[ns] 841s 0.21s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[s] 841s 0.21s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[us] 841s 0.21s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[s] 841s 0.21s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[us] 841s 0.21s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[ms] 841s 0.21s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[ns] 841s 0.19s call tests/indexes/multi/test_indexing.py::test_pyint_engine 841s 0.18s call tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-tanh] 841s 0.18s teardown tests/indexes/timedeltas/test_timedelta_range.py::TestTimedeltas::test_timedelta_range_deprecated_freq[2.5T-5 hours-5 hours 8 minutes-expected_values1-150s] 841s 0.17s call tests/indexes/ranges/test_setops.py::test_range_difference 841s 0.13s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[neither-1] 841s 0.11s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[right-1] 841s 0.11s call tests/indexes/datetimes/test_date_range.py::TestGenRangeGeneration::test_generate[B-offset0] 841s 0.11s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[left-1] 841s 0.10s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[both-1] 841s 0.09s call tests/indexes/datetimes/methods/test_tz_localize.py::TestTZLocalize::test_dti_tz_localize_roundtrip[tzlocal()] 841s 0.08s call tests/indexes/datetimes/test_timezones.py::TestDatetimeIndexTimezones::test_with_tz[tz0] 841s 0.08s call tests/indexes/datetimes/methods/test_tz_localize.py::TestTZLocalize::test_dti_tz_localize_roundtrip[zoneinfo.ZoneInfo(key='US/Pacific')] 841s 0.07s call tests/indexes/datetimes/test_constructors.py::TestDatetimeIndex::test_constructor_datetime64_tzformat[W-SUN] 841s 0.07s call tests/indexes/period/test_partial_slicing.py::TestPeriodIndex::test_range_slice_seconds[period_range] 841s 0.07s call tests/indexes/datetimes/test_timezones.py::TestDatetimeIndexTimezones::test_with_tz[tz1] 841s 0.07s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[neither-10] 841s 0.06s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[both-10] 841s 0.06s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[left-10] 841s 0.06s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[right-10] 841s 0.06s call tests/indexes/multi/test_sorting.py::test_remove_unused_levels_large[datetime64[D]-str] 841s 0.05s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[neither-100] 841s = 16700 passed, 254 skipped, 4 deselected, 46 xfailed, 6 xpassed, 2 warnings in 59.25s = 842s rdjoqkol test state = true 842s + echo 'rdjoqkol test state = true' 842s + for TEST_SUBSET in $modpath/tests/* 842s + echo /usr/lib/python3/dist-packages/pandas/tests/indexing 842s + grep -q -e __pycache__ 842s + PANDAS_CI=1 842s + LC_ALL=C.UTF-8 842s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/indexing 843s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 843s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 843s 843s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 845s ============================= test session starts ============================== 845s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 845s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 845s rootdir: /usr/lib/python3/dist-packages/pandas 845s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 845s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 845s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 845s collected 4389 items 845s 845s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/interval/test_interval.py .............................. 845s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/interval/test_interval_new.py ..................... 845s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_chaining_and_caching.py .. 845s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_datetime.py .. 846s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_getitem.py ............................................................................. 846s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_iloc.py ................ 847s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_indexing_slow.py .......... 848s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_loc.py ................................................................................................................................. 848s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_multiindex.py ................ 848s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_partial.py ............. 848s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_setitem.py ........................... 849s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_slice.py ............................. 849s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_sorted.py ......... 849s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_at.py ......................................... 849s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_categorical.py .................s................................................................................................ 850s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_chaining_and_caching.py .............................. 850s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_check_indexer.py ....................s.... 851s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_coercion.py ..........xxxxxxx...............................................................xx............................................xxxx....x............................................................xxxxx..................xx............................................................................................................................................................................................................x 851s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_datetime.py .........ss 852s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_floats.py ............................................................................................................................................... 852s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_iat.py ..... 852s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_iloc.py .................................................................................................................................................................................................................. 852s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_indexers.py ...... 856s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_indexing.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 860s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_loc.py .............................................................................................................................x...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s...................................................................................................................................................................................................................................................................................................................................................................s.................................... 860s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_na_indexing.py .............................................................................................................................................................................................................................................................................. 861s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_partial.py .................................... 861s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_scalar.py ...................................... 861s 861s =============================== warnings summary =============================== 861s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 861s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-ez67yhl7' 861s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 861s 861s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 861s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-c8wjn9_a' 861s session.config.cache.set(STEPWISE_CACHE_DIR, []) 861s 861s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 861s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 861s ============================= slowest 30 durations ============================= 861s 0.47s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_non_unique_memory_error[900000-100000] 861s 0.17s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-4] 861s 0.16s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-2] 861s 0.16s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-3] 861s 0.16s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-1] 861s 0.15s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-0] 861s 0.14s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-3] 861s 0.14s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-2] 861s 0.14s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-1] 861s 0.13s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-4] 861s 0.13s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-0] 861s 0.10s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_getitem_range_from_spmatrix[int64-coo_matrix] 861s 0.10s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_implicit_take2 861s 0.09s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_str 861s 0.09s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_implicit_take 861s 0.09s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_setting_entire_column 861s 0.07s call tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_groupby_example 861s 0.06s teardown tests/indexing/test_scalar.py::TestMultiIndexScalar::test_multiindex_at_get_one_level 861s 0.05s call tests/indexing/test_loc.py::TestLocSeries::test_loc_nonunique_masked_index 861s 0.05s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_setitem 861s 0.03s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_getitem 861s 0.02s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_doc_examples 861s 0.02s call tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_setitem_multiindex3 861s 0.02s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_loc_axis_arguments 861s 0.01s call tests/indexing/test_loc.py::TestLocCallable::test_frame_loc_setitem_callable 861s 0.01s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_multiindex_slicers_non_unique 861s 0.01s call tests/indexing/multiindex/test_partial.py::TestMultiIndexPartial::test_partial_getitem_loc_datetime[indexer0-exp_idx0-exp_values0] 861s 0.01s call tests/indexing/test_indexing.py::TestMisc::test_rhs_alignment 861s 0.01s call tests/indexing/test_categorical.py::TestCategoricalIndex::test_ix_categorical_index_non_unique[False] 861s 0.01s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_false_positives 861s =========== 4360 passed, 6 skipped, 23 xfailed, 2 warnings in 17.62s =========== 861s rdjoqkol test state = true 861s + echo 'rdjoqkol test state = true' 861s + for TEST_SUBSET in $modpath/tests/* 861s + echo /usr/lib/python3/dist-packages/pandas/tests/interchange 861s + grep -q -e __pycache__ 861s + PANDAS_CI=1 861s + LC_ALL=C.UTF-8 861s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/interchange 862s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 862s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 862s 862s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 862s ============================= test session starts ============================== 862s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 862s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 862s rootdir: /usr/lib/python3/dist-packages/pandas 862s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 862s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 862s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 862s collected 140 items 862s 863s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_impl.py ..sssssssss..............sssss........s..s..ssssssssssssssssssssssssssssssss. 863s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_spec_conformance.py ................ 863s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_utils.py ................sssssssssssssssssssssssssssssss 863s 863s =============================== warnings summary =============================== 863s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 863s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-5tb63ee5' 863s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 863s 863s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 863s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-lr17jih9' 863s session.config.cache.set(STEPWISE_CACHE_DIR, []) 863s 863s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 863s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 863s ============================= slowest 30 durations ============================= 863s 0.03s call tests/interchange/test_impl.py::test_dataframe[4] 863s 0.02s call tests/interchange/test_impl.py::test_dataframe[3] 863s 0.02s call tests/interchange/test_impl.py::test_dataframe[0] 863s 0.01s call tests/interchange/test_impl.py::test_dataframe[1] 863s 0.01s call tests/interchange/test_impl.py::test_dataframe[2] 863s 0.01s call tests/interchange/test_impl.py::test_categorical_dtype[data0] 863s 863s (24 durations < 0.005s hidden. Use -vv to show these durations.) 863s ================== 61 passed, 79 skipped, 2 warnings in 0.64s ================== 863s rdjoqkol test state = true 863s + echo 'rdjoqkol test state = true' 863s + for TEST_SUBSET in $modpath/tests/* 863s + echo /usr/lib/python3/dist-packages/pandas/tests/internals 863s + grep -q -e __pycache__ 863s + PANDAS_CI=1 863s + LC_ALL=C.UTF-8 863s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/internals 864s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 864s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 864s 864s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 865s ============================= test session starts ============================== 865s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 865s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 865s rootdir: /usr/lib/python3/dist-packages/pandas 865s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 865s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 865s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 865s collected 257 items 865s 865s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_api.py ......... 865s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_internals.py .................................................................................................................................................................................................................................................... 866s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_managers.py .... 866s 866s =============================== warnings summary =============================== 866s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 866s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-jx82kj6w' 866s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 866s 866s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 866s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-jtqnbawx' 866s session.config.cache.set(STEPWISE_CACHE_DIR, []) 866s 866s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 866s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 866s ============================= slowest 30 durations ============================= 866s 0.48s call tests/internals/test_managers.py::test_array_manager_depr_env_var[block] 866s 0.41s call tests/internals/test_managers.py::test_array_manager_depr_env_var[array] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[a:i8;e:dt;f:td;g:string] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[c:sparse;d:sparse_na;b:f8] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[a:i8;b:f8;c:c8;d:b] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-int64] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-uint64] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-int64] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-uint64] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-float64] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-uint64] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-int64] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-float64] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-int64] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-float64] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-uint64] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category2-object] 866s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-float64] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f4; b: i8-f8] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: m8[ns]; b: bool-object] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: i8-object] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f8-f8] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category2; b: category2-object] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: m8[ns]; b: i8-object] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: bool-object] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: category-object] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: bool; b: i8-object] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: m8[ns]-object] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f8; b: category-object] 866s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category; b: category2-object] 866s ======================= 257 passed, 2 warnings in 2.18s ======================== 867s rdjoqkol test state = true 867s + echo 'rdjoqkol test state = true' 867s + for TEST_SUBSET in $modpath/tests/* 867s + echo /usr/lib/python3/dist-packages/pandas/tests/io 867s + grep -q -e __pycache__ 867s + PANDAS_CI=1 867s + LC_ALL=C.UTF-8 867s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/io 868s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 868s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 868s 868s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 878s ============================= test session starts ============================== 878s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 878s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 878s rootdir: /usr/lib/python3/dist-packages/pandas 878s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 878s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 878s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 878s collected 15519 items / 201 deselected / 2 skipped / 15318 selected 878s 878s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odf.py ..... 878s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odswriter.py .......... 879s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_openpyxl.py ...................................................... 896s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py ......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss....................................ssssss......ssssssssssssssssssssssssssssss............ss..ssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss............ss..ssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss............ss..sssssssssss..s..s.sssssssssssssssssss..s..s.sssssssssssssssssssssssssssssss............ss..ssssssssss......s.sssssssssssssssssss..ssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss.xx.xxs.sssss......s.sssss......s.sssss......s.sssss....................................ssssss......ssssssssssssssssssssssssssssss......s.sssss......s.sssss......s.sssssssssssssssssssssssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss............ss..ssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss....................................ssssss......ssssssssssssssssssssssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......sssssss......sssssss......s.sssss......s.sssss......s.sssss......s.sssss..................sss...sssssssssssssss......s.sssss......s.sssss....................................ssssss......ssssssssssssssssssssssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss............ss..ssssssssss......s.sssss......s.sssss......sssssss...ssss.sssss 898s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_style.py ...................................................................................................................................s 914s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_writers.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 914s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlrd.py ....... 914s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlsxwriter.py ..... 914s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_bar.py ..........................................................................................................................s 914s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_exceptions.py ... 915s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_format.py ......................................................................................................... 915s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_highlight.py ................................................................................................ 916s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_html.py ........................................................................................... 916s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_matplotlib.py ........................................................... 916s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_non_unique.py ......... 917s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_style.py ................................................................................................................................................................................................. 918s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_latex.py ............................................................................................................................................................ 918s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_string.py ..... 918s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_tooltip.py .... 918s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_console.py ........... 918s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_css.py ............................................................................................... 918s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_eng_formatting.py ....... 919s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_format.py .................................................................................................................................................................................. 919s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_ipython_compat.py ss..s 919s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_printing.py ......... 920s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_csv.py ..........s.................................................................................. 920s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_excel.py .......................................................................................................................................................................................................................................................................................................................................................................................................................... 922s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_html.py .....................................................................................................................................................................................................................................................................................................................................................................s................... 922s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_latex.py ............................................................................................ 922s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_markdown.py .......... 923s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_string.py ...............................................s........................................... 923s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_compression.py ........sssssss.................s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s....... 923s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_deprecated_kwargs.py . 924s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_json_table_schema.py ...........................................................................................x...x...x...x...x...x...x...x...x...x......x...x...x...x...x...x...x...x...x...x........................... 924s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_json_table_schema_ext_dtype.py ..................... 924s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_normalize.py ..................................................... 930s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py ...........................................................................................................xxxx................................xxx........................................................................................................................................................................s........xxxxxxxxxxxxxxxxxx................................................................xx.............s.....x........ssssssssssssssssssssssssssssssss...sssss.s. 930s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_readlines.py ..s.s.....ss.s.s.s.s......ssss....s..ss..ss.s.s........... 931s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_ujson.py ................................................................................................................................................................................................................... 932s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_chunksize.py ......ss.........sss......ss...s...s......ss...s...s...s......ss...s...s...s 932s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_common_basic.py ....s...s...s...ss..s...s......ss.........sss...s...s...s...s...s.........sss............ssss......ss...s...s......ss.........sss...s......ss...s.........sss...s...s......ss...s...s...............sssss...s...s...s......ss...s......ss......ss...s...s...s...s...s...s 932s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_data_list.py ...s...s...s...s 932s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_decimal.py ......ss...s 933s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_file_buffer_url.py ...s...s...s...s...s.................................sssssssssss...s...s...s...s...s...s...s...s............ssss.....................sssssss...s...s...s...s 933s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_float.py ...s.......s.....................sss....x.....x...ss 934s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_index.py ......ss......ss...s............ssss...s...s...s...s...s...s...s 934s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_inf.py ......ss......ss...s 934s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_ints.py ...s............ssss...s......ss...s.........sss.........sss......ss......ss...s 934s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_iterator.py ...s...s...s.........sss...s 934s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_read_errors.py ...s...s...s.........sss...s..................ssssss...s...s...s...s...s..xs...s...s...s...s 934s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_verbose.py ...s...s 934s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/dtypes/test_categorical.py .........sss......ss...s...s...s...s...s...s........................ssssssss...s...s...s...s...s............ssss...s 938s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/dtypes/test_dtypes_basic.py ............ssss...s...s...s...s......................................................ssssssssssssssssss...s...s.............................x.x.x...................................................................................................................................................................x.x.x.x.x.x.x.x.x.x.x.x.........................................................................................................................................................................................................................................................................................................................x.x.x.x.x.x.x.x.x.x.x.x...................................................................................................................................................................................................................s......ss...s...s........................ssssssss......ss...s...s...s...sssssssss...sssss...sssssssssssssssssssssssssssss...s...s 938s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/dtypes/test_empty.py ...s...s...s...s...s...s...s...s........................ssssssss 939s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_c_parser_only.py .......................................................................... 939s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_comment.py ......ss.........sss...s...s...s..................ssssss......ssxx.s 942s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_compression.py .........sss......ss...s...s.x.x.xss......ss.x.x.xss......ss.x.x.xss......ss.x.x.xss......ss.x.x.xss......ss.x.x.xss......ss..................ssssss......................................................ssssssssssssssssss.........sss...s...s...s 942s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_concatenate_chunks.py ss 942s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_converters.py ...s............ssss...s...s...s......ss...s...s 942s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_dialect.py ...s...s...s......................................................ssssssssssssssssss..................ssssss 944s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_encoding.py ...s...s..................ssssss...s...s...............sssss......................................................ssssssssssssssssss.........sss............................................................................................................ssssssssssssssssssssssssssssssssssss...s....................sssss...s...s......ss 944s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_header.py ...s...s......ss......ss...s...s...s.........sss.........sss.........sss.........sss...s...s...s...s......ss......ss......ss......ss...s.........sss........................ssssssss...s...s...s...s...s...s...s...s...ss 945s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_index_col.py ......ss...s...s...s..............................ssssssssss...s...............sssss...s...s...s...s...s...s...s...s......ss...s 945s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_mangle_dupes.py ...s...s...s.........sss.........sss...s...s...s......ss 945s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_na_values.py ...s...s..........................................ssssssssssssss...s......ss...s...s.........sss............ssss...s...s...s......ss......ss...s......ss...s...s.........sss...s......ss...s......ss..................ssssss...s...s...s...s...s 954s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py ................ssss.....ssssssssssssssssss 956s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_parse_dates.py ...s...s...s......ss..............ss...s...s...s...s......ss...s...s...s...s...sxxxxxxss......ss......ss......ss...s.........sss...s...s...s......ss.........sss............ssss......ss...s......ss......ss............ssss...s......ss...s......ss......ss...s...s...s............ssss...s..................ssssss.........sss......ss............................sssssssss...s...s......ss...s...s......s......ss...s...s...s......ss...s...s...s 957s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_python_parser_only.py ..................................................................................... 957s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_quoting.py .........sss......ss...s..................ssssss............ssss...............sssss......ss......ss......ss 957s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_read_fwf.py ..........................................................................sss.. 957s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_skiprows.py ......ss...s...s.........sss...s.........sss........xsss...s......ss...s...s...s...s...s 958s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_textreader.py ..................................... 958s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_unsupported.py ..........s...s..xs...s 958s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_upcast.py ...........................ssss 958s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_parse_dates.py ......ss...s...s...s............ssss 958s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_strings.py ...s...s......ss......ss 958s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_usecols_basic.py ...s......ss...s......ss...s...s...s......ss............ssss...s...s...s...s...s...s......ss...s...s......ss......ss......ss.....................sssssss......ss......ss...s...s...s 961s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....x................ 962s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_categorical.py ..... 962s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_compat.py .... 962s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_complex.py ......... 962s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_errors.py ................ 967s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................xxxxxxxxx................................................................................................................................... 967s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_keys.py .... 968s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_put.py ...................... 968s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_pytables_missing.py s 968s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_read.py ....................s 968s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_retain_attributes.py ..... 969s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_round_trip.py ..............................s 973s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_select.py ...x.....x............... 977s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................x..................... 977s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_subclass.py .. 977s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_time_series.py .... 978s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_timezones.py .......................................................................... 979s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_byteswap.py .......... 979s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas.py ... 979s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas7bdat.py ....................... 980s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_xport.py ....... 980s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_clipboard.py .......QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-ubuntu' 982s ...............................................................................................................................................................................................................................................................................................................................ssssss.. 982s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_common.py .......................................................s....s........ss.......s.........s.......s......................................... 984s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_compression.py ........................................................................................................................................ 984s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_fsspec.py .........ssssssssss..........s 984s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gbq.py .. 984s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gcs.py ssssssssssssssssss. 996s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py .........ssssss...............................................................................................................................s.................... 998s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py ...ss.......ss.......ss....ss 998s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_parquet.py .ssss.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.ssssssss 1006s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_pickle.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 1006s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_s3.py sss 1006s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_spss.py .......s.. 1025s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py ssss....ssssss....ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss...ssss....ssssss...ssss...ssss...ssss...xssssssssssssssxxxxssssss...ssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss...xssssss...xssssss...xssssss....ssssss....ssssss....ssssss...xssssss...xssssss...xssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss...xssssss...xssssss...xss.ssss...xssssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss....ssssss....ssssss...ssss...ssss...xss.ss...ssss..sssss..sssss..s.ssssss....ssssss...ssss...ssss...ssssxxxssss...ssssxxxssssssssssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss....ssssss....ssssss....ssssss..xssss..sssss..sssss..sssss...ssss...ssss...ssss...ssss..sssss...xssssss....ssssss...ssss....ss..ssss....ssssss....ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssxxxxssssssxxxxssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ssssss....ss....s..ss................ 1034s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_stata.py ..............................................................................................................................................................................................................................................................................................................................................................................s.................................................................................................................................................................................................................................................... 1034s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_to_xml.py ........................................................................s...............................................................ss 1037s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml.py ........................................................................................s............................................................................s......s......s......s......s......s......s......s......s......s......s......s..s.sss.sss. 1038s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml_dtypes.py .............................................. 1038s 1038s =============================== warnings summary =============================== 1038s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1038s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-0owl6ykm' 1038s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1038s 1038s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1038s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-tp3epsxg' 1038s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1038s 1038s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1038s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1038s ============================= slowest 30 durations ============================= 1038s 1.67s call tests/io/test_html.py::TestReadHtml::test_banklist_url[bs4] 1038s 1.07s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-5] 1038s 1.07s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-4] 1038s 1.03s call tests/io/pytables/test_store.py::test_no_track_times 1038s 0.98s call tests/io/pytables/test_select.py::test_select_iterator_complete_8014 1038s 0.88s call tests/io/test_html.py::TestReadHtml::test_banklist_no_match[bs4] 1038s 0.59s call tests/io/pytables/test_select.py::test_select_iterator_non_complete_8014 1038s 0.58s call tests/io/pytables/test_categorical.py::test_categorical 1038s 0.51s call tests/io/test_compression.py::test_with_missing_lzma_runtime 1038s 0.50s teardown tests/io/json/test_pandas.py::TestPandasContainer::test_url[updated_at-dtype2] 1038s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-pickle_respnder-read_pickle] 1038s 0.50s teardown tests/io/parser/common/test_file_buffer_url.py::test_url[c_low] 1038s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-c-infer] 1038s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zstd-c-infer] 1038s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zstd-python-explicit] 1038s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-stata_responder-read_stata] 1038s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_multiple_matches[bs4] 1038s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[bz2-c-infer] 1038s 0.50s teardown tests/io/parser/test_network.py::test_url_encoding_csv 1038s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[bz2-c-explicit] 1038s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[xz-python-infer] 1038s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-c-explicit] 1038s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[xz-python-explicit] 1038s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zstd-c-explicit] 1038s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zstd-python-infer] 1038s 0.50s teardown tests/io/excel/test_readers.py::TestReaders::test_read_from_http_url[(None, '.xls')] 1038s 0.50s teardown tests/io/xml/test_xml.py::test_url_path_error[lxml] 1038s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_bad_url_protocol[bs4] 1038s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_bad_url_protocol[lxml] 1038s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-html_responder-] 1038s = 12148 passed, 3017 skipped, 201 deselected, 155 xfailed, 2 warnings in 170.44s (0:02:50) = 1039s rdjoqkol test state = true 1039s + echo 'rdjoqkol test state = true' 1039s + for TEST_SUBSET in $modpath/tests/* 1039s + echo /usr/lib/python3/dist-packages/pandas/tests/libs 1039s + grep -q -e __pycache__ 1039s + PANDAS_CI=1 1039s + LC_ALL=C.UTF-8 1039s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/libs 1040s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1040s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1040s 1040s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1041s ============================= test session starts ============================== 1041s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1041s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1041s rootdir: /usr/lib/python3/dist-packages/pandas 1041s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1041s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1041s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1041s collected 2279 items 1041s 1044s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_hashtable.py ..............s.....................................................................s.............s.......................................................s.............s.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s................................................................................................................................................................................................. 1044s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_join.py ................. 1044s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_lib.py .................................................................................. 1044s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_libalgos.py ........ 1044s 1044s =============================== warnings summary =============================== 1044s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1044s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-jyqi3ibw' 1044s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1044s 1044s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1044s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-pqbkzwv1' 1044s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1044s 1044s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1044s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1044s ============================= slowest 30 durations ============================= 1044s 0.02s teardown tests/libs/test_libalgos.py::TestInfinity::test_infinity_against_nan 1044s 0.01s call tests/libs/test_libalgos.py::TestInfinity::test_infinity_sort 1044s 0.01s call tests/libs/test_hashtable.py::test_unique_label_indices 1044s 1044s (27 durations < 0.005s hidden. Use -vv to show these durations.) 1044s ================= 2273 passed, 6 skipped, 2 warnings in 3.85s ================== 1044s rdjoqkol test state = true 1044s + echo 'rdjoqkol test state = true' 1044s + for TEST_SUBSET in $modpath/tests/* 1044s + echo /usr/lib/python3/dist-packages/pandas/tests/plotting 1044s + grep -q -e __pycache__ 1044s + PANDAS_CI=1 1044s + LC_ALL=C.UTF-8 1044s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/plotting 1045s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1045s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1045s 1045s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1047s ============================= test session starts ============================== 1047s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1047s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1047s rootdir: /usr/lib/python3/dist-packages/pandas 1047s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1047s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1047s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1047s collected 1423 items / 212 deselected / 1211 selected 1047s 1068s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame.py ..................................................XX.........................s.s.s.s....................................................................................................x...................................................................................... 1073s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_color.py ......................................................................................... 1074s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_groupby.py ...... 1075s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_legend.py x..................... 1083s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_subplots.py .........x....................XX................................................................... 1084s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_hist_box_by.py ............................. 1084s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_backend.py .....s. 1088s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_boxplot_method.py .................................................... 1088s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_common.py ... 1090s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_converter.py ............................................ 1106s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_datetimelike.py ...............................................................................................................x..........................................x.......................x...............x..... 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_groupby.py ................. 1112s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_hist_method.py ...........................x..x...................................................... 1121s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_misc.py s....................sss...................sss...................sss.................................. 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_series.py ...............................XXXX.............................x........................................................x......................... 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_style.py ...................................... 1125s 1125s =============================== warnings summary =============================== 1125s tests/plotting/frame/test_frame.py: 11 warnings 1125s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2650: RuntimeWarning: divide by zero encountered in scalar divide 1125s x_scale = 1.0 / inw 1125s 1125s tests/plotting/frame/test_frame.py: 11 warnings 1125s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2652: RuntimeWarning: invalid value encountered in scalar multiply 1125s self._mtx = np.array([[x_scale, 0.0, -inl*x_scale], 1125s 1125s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1125s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-xosguh2u' 1125s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1125s 1125s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1125s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-zvaw7zhb' 1125s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1125s 1125s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1125s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1125s ============================= slowest 30 durations ============================= 1125s 0.95s call tests/plotting/test_datetimelike.py::TestTSPlot::test_finder_daily 1125s 0.72s call tests/plotting/test_converter.py::test_registry_mpl_resets 1125s 0.69s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[True] 1125s 0.65s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[bar] 1125s 0.62s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_ts_share_axes 1125s 0.59s call tests/plotting/test_misc.py::TestSeriesPlots::test_bootstrap_plot 1125s 0.58s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[barh] 1125s 0.57s call tests/plotting/test_converter.py::TestRegistration::test_dont_register_by_default 1125s 0.56s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[True] 1125s 0.47s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharex_and_ax 1125s 0.46s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[False] 1125s 0.46s call tests/plotting/test_misc.py::test_savefig[index2-data0-hexbin] 1125s 0.45s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[False] 1125s 0.44s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharey_and_ax 1125s 0.43s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[line] 1125s 0.42s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_kde_df 1125s 0.42s call tests/plotting/test_misc.py::test_savefig[index0-data0-hexbin] 1125s 0.41s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[True-UserWarning-3-layout0] 1125s 0.40s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_df_gridspec_patterns_vert_horiz 1125s 0.40s call tests/plotting/test_misc.py::test_savefig[index1-data0-hexbin] 1125s 0.39s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[False-None-1-layout1] 1125s 0.37s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_constrained_layout 1125s 0.33s call tests/plotting/test_boxplot_method.py::TestDataFramePlots::test_stacked_boxplot_set_axis 1125s 0.32s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data0] 1125s 0.32s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data1] 1125s 0.30s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df 1125s 0.29s call tests/plotting/test_hist_method.py::TestDataFrameGroupByPlots::test_histtype_argument[barstacked-True] 1125s 0.29s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_bar_bottom_left_subplots 1125s 0.28s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_dup_columns_secondary_y 1125s 0.27s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_plot_xy 1125s = 1177 passed, 15 skipped, 212 deselected, 11 xfailed, 8 xpassed, 24 warnings in 80.24s (0:01:20) = 1126s rdjoqkol test state = true 1126s + echo 'rdjoqkol test state = true' 1126s + for TEST_SUBSET in $modpath/tests/* 1126s + echo /usr/lib/python3/dist-packages/pandas/tests/reductions 1126s + grep -q -e __pycache__ 1126s + PANDAS_CI=1 1126s + LC_ALL=C.UTF-8 1126s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reductions 1127s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1127s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1127s 1127s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1127s ============================= test session starts ============================== 1127s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1127s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1127s rootdir: /usr/lib/python3/dist-packages/pandas 1127s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1127s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1127s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1127s collected 550 items 1127s 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_reductions.py ........................................................................................+ echo 'rdjoqkol test state = true' 1129s + for TEST_SUBSET in $modpath/tests/* 1129s .............................................................................................................................................................................................................................................s....................................................................................................................................... 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_stat_reductions.py ......................................................................................... 1129s 1129s =============================== warnings summary =============================== 1129s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1129s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-6lof2vvc' 1129s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1129s 1129s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1129s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-s0_9_dwc' 1129s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1129s 1129s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1129s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1129s ============================= slowest 30 durations ============================= 1129s 0.38s call tests/reductions/test_stat_reductions.py::TestSeriesStatReductions::test_skew 1129s 0.03s call tests/reductions/test_reductions.py::TestReductions::test_same_tz_min_max_axis_1[max-a] 1129s 0.03s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-False] 1129s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-True] 1129s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-False] 1129s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-False] 1129s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-True] 1129s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-True] 1129s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-True] 1129s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-False] 1129s 1129s (20 durations < 0.005s hidden. Use -vv to show these durations.) 1129s ================== 549 passed, 1 skipped, 2 warnings in 2.16s ================== 1129s rdjoqkol test state = true 1129s + echo /usr/lib/python3/dist-packages/pandas/tests/resample 1129s + grep -q -e __pycache__ 1129s + PANDAS_CI=1 1129s + LC_ALL=C.UTF-8 1129s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/resample 1130s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1130s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1130s 1130s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1131s ============================= test session starts ============================== 1131s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1131s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1131s rootdir: /usr/lib/python3/dist-packages/pandas 1131s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1131s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1131s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1131s collected 4179 items 1131s 1138s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_base.py ..............................................................................................................................................................xxx......xxx......xxx......xxx......xxx......xxx......xxx......xxx......xxx......xxx......xxx......xxx......xxx......xxx......xxx......xxx............................................................................................................................................................................................................................................................................................................................................................................................................................................................. 1154s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_datetime_index.py ................................................................................ssss............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...x...x...x..........................................................................................................................................................................................................................................................................................................................................................................ss 1159s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_period_index.py .................................................................................................................................................................................................................................................................................................................................................................................................................................x.................................................................................. 1160s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resample_api.py ..................................................................................................................................................................................................... 1161s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resampler_grouper.py s................................................... 1161s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_time_grouper.py .........................x...................... 1161s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_timedelta.py .......................s 1161s 1161s =============================== warnings summary =============================== 1161s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1161s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-9xwb__hu' 1161s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1161s 1161s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1161s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-us_gxelt' 1161s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1161s 1161s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1161s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1161s ============================= slowest 30 durations ============================= 1161s 0.18s call tests/resample/test_datetime_index.py::test_resample_dtype_coercion[s] 1161s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-1] 1161s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-2] 1161s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-3] 1161s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-1] 1161s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-2] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-1] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-3] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-3] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-21600-s-0.25-D-1] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-86400-s-1-D-2] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-86400-s-1-D-1] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-21600-s-0.25-D-3] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-3600-s-1-h-3] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-1] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-2] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-3] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-86400-s-1-D-3] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-86400-s-1-D-3] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-1] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-21600-s-0.25-D-2] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-2] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-2] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-43200-s-0.5-D-1] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-43200-s-0.5-D-2] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-3] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-1] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-2] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_ohlc[ms] 1161s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-2] 1161s =========== 4117 passed, 8 skipped, 54 xfailed, 2 warnings in 31.47s =========== 1162s rdjoqkol test state = true 1162s + echo 'rdjoqkol test state = true' 1162s + for TEST_SUBSET in $modpath/tests/* 1162s + echo /usr/lib/python3/dist-packages/pandas/tests/reshape 1162s + grep -q -e __pycache__ 1162s + PANDAS_CI=1 1162s + LC_ALL=C.UTF-8 1162s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reshape 1162s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1162s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1162s 1162s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1165s ============================= test session starts ============================== 1165s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1165s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1165s rootdir: /usr/lib/python3/dist-packages/pandas 1165s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1165s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1165s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1165s collected 2610 items / 1 deselected / 2609 selected 1165s 1165s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append.py .................................................................................. 1165s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append_common.py ...........................sssssssss....................................................... 1165s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_categorical.py ............. 1166s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_concat.py .............................................................................................. 1166s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_dataframe.py ..................... 1166s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_datetimes.py ..................................................................................................x......... 1166s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_empty.py .....................s.....s.....s.....s.....s.......... 1167s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_index.py ............................................................. 1167s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_invalid.py ....... 1167s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_series.py ............. 1167s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_sort.py .......... 1167s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_join.py .......s..........................s....................................... 1172s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss..............................................................................................................................................................................................................................ss..........................................................................................................................................................................................................................................................................ssss........ 1173s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_asof.py .s...................................................................................................s.....................s....s.s.s.s.............sss.. 1173s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_cross.py ................. 1173s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_index_as_string.py ................................................................................ 1174s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_ordered.py ..................... 1174s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_multi.py .....s.s.................................. 1175s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_crosstab.py ..................................... 1176s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_cut.py ..................................................................................................................................... 1176s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_from_dummies.py ......................................... 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_get_dummies.py ...................................................................................................................................................ss 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_melt.py ..........................................................s 1180s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot.py ...........................................................................xx................................................................................................. 1180s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot_multilevel.py .......... 1181s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_qcut.py ................................................................................ 1181s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_union_categoricals.py .......................................... 1181s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_util.py ................. 1181s 1181s =============================== warnings summary =============================== 1181s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1181s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-34bojxm1' 1181s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1181s 1181s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1181s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-zo9iixsy' 1181s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1181s 1181s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1181s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1181s ============================= slowest 30 durations ============================= 1181s 0.10s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_multi_functions 1181s 0.10s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize 1181s 0.09s call tests/reshape/merge/test_join.py::TestJoin::test_full_outer_join 1181s 0.07s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_non_unique_indexes 1181s 0.07s call tests/reshape/concat/test_concat.py::TestConcatenate::test_concat_order 1181s 0.07s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_normalize 1181s 0.07s call tests/reshape/test_pivot.py::TestPivotTable::test_margins 1181s 0.06s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_dropna6 1181s 0.06s call tests/reshape/merge/test_join.py::TestJoin::test_right_outer_join 1181s 0.05s call tests/reshape/test_qcut.py::test_qcut_binning_issues 1181s 0.05s call tests/reshape/test_pivot.py::TestPivotTable::test_daily 1181s 0.04s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize_arrays 1181s 0.04s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper 1181s 0.04s call tests/reshape/test_crosstab.py::test_categoricals[category-category] 1181s 0.04s call tests/reshape/test_crosstab.py::test_categoricals[int64-category] 1181s 0.04s call tests/reshape/test_crosstab.py::test_categoricals[category-int64] 1181s 0.04s call tests/reshape/merge/test_multi.py::TestMergeMulti::test_compress_group_combinations 1181s 0.04s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_margins_set_margin_name 1181s 0.04s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[array] 1181s 0.03s call tests/reshape/test_crosstab.py::test_categoricals[int64-int64] 1181s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[list] 1181s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[tuple] 1181s 0.03s call tests/reshape/merge/test_multi.py::TestMergeMulti::test_left_join_multi_index[True-False] 1181s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper_double 1181s 0.03s call tests/reshape/merge/test_join.py::TestJoin::test_join_many_non_unique_index 1181s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_duplicate_names 1181s 0.03s call tests/reshape/merge/test_merge.py::TestMerge::test_validation 1181s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_table_margins_name_with_aggfunc_list 1181s 0.03s call tests/reshape/merge/test_join.py::TestJoin::test_left_outer_join 1181s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize_multiple_columns 1181s ==== 2561 passed, 45 skipped, 1 deselected, 3 xfailed, 2 warnings in 18.23s ==== 1181s rdjoqkol test state = true 1181s + echo 'rdjoqkol test state = true' 1181s + for TEST_SUBSET in $modpath/tests/* 1181s + echo /usr/lib/python3/dist-packages/pandas/tests/scalar 1181s + grep -q -e __pycache__ 1181s + PANDAS_CI=1 1181s + LC_ALL=C.UTF-8 1181s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/scalar 1182s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1182s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1182s 1182s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1185s ============================= test session starts ============================== 1185s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1185s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1185s rootdir: /usr/lib/python3/dist-packages/pandas 1185s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1185s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1185s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1185s collected 4353 items 1185s 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_arithmetic.py ............................................ 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_constructors.py ......... 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_contains.py ................ 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_formats.py . 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_interval.py ............................................ 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_overlaps.py ................................................................................................................................................................. 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_arithmetic.py .................................................................................... 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_asfreq.py ....................... 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_period.py ............................................................................................................................................................................................................................................................................................................... 1187s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_na_scalar.py .....................................................................................ss.....ss.....ss................................................................................................................................................................................ 1187s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_nat.py ........................................................................................................................s............s............................................................................................................................................................................................................................ 1187s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_as_unit.py .... 1188s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_round.py ................... 1188s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_arithmetic.py ................................................................................................................................ 1188s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_constructors.py ................................................................................................................................................................................................................................................................................................................... 1188s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_formats.py .............. 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_timedelta.py .................................................................x............ 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_as_unit.py .... 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_normalize.py ................................................................................................................................................................. 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_replace.py ............................................................................................................................ 1193s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_round.py ....................................................................................................................................................................................... 1193s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_timestamp_method.py . 1193s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_julian_date.py ..... 1193s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_pydatetime.py ....... 1193s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_convert.py ............................................................................... 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_localize.py ................................................................................................................................................................................................. 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_arithmetic.py ............................................................................................................. 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_comparisons.py .............................. 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_constructors.py ..................................................................xxx.............................................................. 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_formats.py ........................................................................... 1199s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timestamp.py .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................................................................................................................... 1199s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timezones.py .................... 1199s 1199s =============================== warnings summary =============================== 1199s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1199s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-rc4n_9_k' 1199s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1199s 1199s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1199s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-an0mj19i' 1199s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1199s 1199s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1199s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1199s ============================= slowest 30 durations ============================= 1199s 3.11s call tests/scalar/timedelta/test_timedelta.py::TestTimedeltas::test_hash_equality_invariance 1199s 0.20s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[round] 1199s 0.19s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[floor] 1199s 0.18s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[floor] 1199s 0.17s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[ceil] 1199s 0.17s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[ceil] 1199s 0.17s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[round] 1199s 0.11s call tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_dow_parametric 1199s 0.09s teardown tests/scalar/timestamp/test_timezones.py::TestTimestampTZOperations::test_timestamp_timetz_equivalent_with_datetime_tz[zoneinfo.ZoneInfo(key='UTC')] 1199s 0.01s call tests/scalar/test_nat.py::test_nat_vector_field_access 1199s 0.01s call tests/scalar/period/test_period.py::TestPeriodMethods::test_to_timestamp 1199s 0.01s call tests/scalar/period/test_arithmetic.py::TestPeriodArithmetic::test_period_add_offset 1199s 0.01s call tests/scalar/period/test_arithmetic.py::TestPeriodArithmetic::test_period_sub_offset 1199s 0.01s call tests/scalar/period/test_period.py::TestPeriodProperties::test_period_deprecated_freq 1199s 1199s (16 durations < 0.005s hidden. Use -vv to show these durations.) 1199s =========== 4340 passed, 8 skipped, 5 xfailed, 2 warnings in 16.88s ============ 1199s + echo 'rdjoqkol test state = true' 1199s + for TEST_SUBSET in $modpath/tests/* 1199s rdjoqkol test state = true 1199s + echo /usr/lib/python3/dist-packages/pandas/tests/series 1199s + grep -q -e __pycache__ 1199s + PANDAS_CI=1 1199s + LC_ALL=C.UTF-8 1199s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/series 1200s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1200s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1200s 1200s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1206s ============================= test session starts ============================== 1206s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1206s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1206s rootdir: /usr/lib/python3/dist-packages/pandas 1206s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1206s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1206s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1206s collected 13032 items / 2 skipped 1206s 1206s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_cat_accessor.py ................... 1214s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_dt_accessor.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1214s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_sparse_accessor.py . 1214s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_str_accessor.py .. 1214s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_datetime.py ................. 1214s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_delitem.py .... 1214s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_get.py ............ 1214s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_getitem.py .............................................................................................. 1216s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1216s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_mask.py .... 1216s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_set_value.py ... 1221s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_setitem.py .......................................................................................................................sss....sss....sss....sss....sss....sss....sss....sss....sss....sss....sss....sss...s...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...ssss...sss.................................................................................................................................................................................sssssssss..................ssssssssssssssssss............................................................ssssssssssss..........................................................................................ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...........................................................................................................................sss..................ssssssssssss...........................sss.......sssssssssssssssssssssssssss.................................................................................sssssssss.................................ssssss.....................sssssssss........................ssssss........................ssssssssssss....................................ssssssssssss..........................................ssssssssssssssssss................................................ssssssssssss....................................ssssssssssss.........................................................................................................sssssssssssssssssssssssssss.........sssssssss..............................ssssssssssss.................................sssssssss....................................ssssssssssssssssss................................................................................................................................................................................................... 1221s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_take.py .... 1222s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_where.py ......................................................................................................................................................................................................... 1222s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_xs.py ...... 1222s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_add_prefix_suffix.py ... 1222s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_align.py ............................................................................................................... 1222s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_argsort.py ......... 1222s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_asof.py ....... 1223s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_astype.py ........................................................s....s..........................................................................x........sssssssss.................s 1223s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_autocorr.py . 1223s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_between.py ....... 1223s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_case_when.py ........... 1223s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_clip.py ....s.....s.....s.....s.....s.....s.....s.....s.....s.....s............ 1223s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine.py . 1223s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine_first.py .............................. 1223s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_compare.py ............ 1225s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_convert_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s......ss 1225s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_copy.py .......... 1225s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_count.py ... 1226s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_cov_corr.py ................ 1226s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_describe.py ...................................................... 1226s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_diff.py ....... 1226s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop.py ............................. 1227s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop_duplicates.py ..................................................................ssssss.............................................................................................................................................................................................................................................................................................................ss 1227s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dropna.py ........... 1227s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dtypes.py . 1227s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_duplicated.py .................. 1227s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_equals.py ..................................................... 1227s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_explode.py ...............ssss 1227s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_fillna.py ....................x.x.x................................................................................................................................. 1227s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_get_numeric_data.py . 1227s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_head_tail.py . 1227s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_infer_objects.py ....... 1228s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_info.py ........x..... 1228s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_interpolate.py x.........................................................................................................................................................................................................x.x............. 1228s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_monotonic.py .. 1229s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_unique.py ........ 1229s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isin.py ......................................... 1229s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isna.py .. 1229s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_item.py . 1229s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_map.py ......ss...................................xxx....................................................... 1229s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_matmul.py . 1229s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nlargest.py ................................................................. 1229s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nunique.py .. 1229s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pct_change.py .............. 1229s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pop.py . 1230s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_quantile.py ........................................ 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rank.py .......................................................................................................ssssssssssssssssssssssssssssss........................................................ssssssssssssssss.....ss.....ss.....ss.....ss.....ss.....................................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss. 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex.py ................................... 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex_like.py .. 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename.py ................ 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename_axis.py ..... 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_repeat.py ... 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_replace.py ...........................s.......................................................................... 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reset_index.py ........s...... 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_round.py ......................................................................................... 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_searchsorted.py ........ 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_set_name.py .. 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_size.py ....... 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_index.py .............................................. 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_values.py .............. 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_csv.py ................................... 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_dict.py ...... 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_frame.py ... 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_numpy.py ...s. 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tolist.py ..........sss 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_truncate.py .... 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tz_localize.py ................................................................ 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unique.py ....... 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unstack.py ....... 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_update.py ....................s..... 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_value_counts.py ................... 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_values.py ... 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_view.py .................................................. 1233s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_api.py ................................s.......................................................................................................................................................... 1242s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...............................x............. 1243s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_constructors.py ......................................................................................................................................................................................................................................x.........x............................................................................................s.................................xx.................................................sssssss.s...................... 1243s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_cumulative.py ....................................... 1244s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_formats.py .................................................. 1244s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_iteration.py ....... 1244s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_logical_ops.py ..........................xs 1244s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_missing.py ...x.. 1244s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_npfuncs.py ....s 1244s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_reductions.py ..............s............... 1245s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_subclass.py ......... 1246s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_ufunc.py .....................................................................xxxx........................................................................................................................................ 1246s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_unary.py .......................... 1246s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_validate.py ............................ 1246s 1246s =============================== warnings summary =============================== 1246s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1246s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-2xmo12mx' 1246s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1246s 1246s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1246s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-txr79dwv' 1246s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1246s 1246s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1246s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1246s ============================= slowest 30 durations ============================= 1246s 0.50s call tests/series/test_formats.py::TestSeriesRepr::test_latex_repr 1246s 0.36s call tests/series/methods/test_cov_corr.py::TestSeriesCorr::test_corr[float64] 1246s 0.30s call tests/series/methods/test_rank.py::test_pct_max_many_rows 1246s 0.13s call tests/series/test_arithmetic.py::TestNamePreservation::test_series_ops_name_retention[numexpr-names3-truediv-True-Series] 1246s 0.10s teardown tests/series/test_validate.py::test_validate_bool_args[5.0-drop_duplicates] 1246s 0.09s call tests/series/methods/test_convert_dtypes.py::TestSeriesConvertDtypes::test_convert_dtypes[test_cases14-params5] 1246s 0.08s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[br_FR.UTF-8] 1246s 0.06s call tests/series/methods/test_isin.py::TestSeriesIsIn::test_isin 1246s 0.03s call tests/series/test_api.py::TestSeriesMisc::test_inspect_getmembers 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[sd_PK.UTF-8] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[se_NO.UTF-8] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[shn_MM.UTF-8] 1246s 0.02s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx1] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[es_EC.ISO8859-1] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[es_ES.ISO8859-1] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[es_GT.UTF-8] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[es_ES.UTF-8] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[es_GT.ISO8859-1] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[es_EC.UTF-8] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[so_DJ.UTF-8] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[sr_RS.UTF-8] 1246s 0.02s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx0] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[sgs_LT.UTF-8] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[sr_RS.UTF-8@latin] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ssy_ER.UTF-8] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ckb_IQ.UTF-8] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[so_SO.ISO8859-1] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[sr_ME.UTF-8] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[gbm_IN.UTF-8] 1246s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[es_DO.UTF-8] 1246s ========= 12405 passed, 606 skipped, 23 xfailed, 2 warnings in 46.13s ========== 1247s + echo 'rdjoqkol test state = true' 1247s + for TEST_SUBSET in $modpath/tests/* 1247s rdjoqkol test state = true 1247s + grep -q -e __pycache__ 1247s + echo /usr/lib/python3/dist-packages/pandas/tests/strings 1247s + PANDAS_CI=1 1247s + LC_ALL=C.UTF-8 1247s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/strings 1248s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1248s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1248s 1248s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1249s ============================= test session starts ============================== 1249s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1249s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1249s rootdir: /usr/lib/python3/dist-packages/pandas 1249s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1249s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1249s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1249s collected 3604 items 1249s 1254s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_api.py ..ss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x.........................................................................................................xx............xx......xx............................xx........................xxxx..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss 1255s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_case_justify.py ..ss...ss.......ssssss...ss....ss..ss...ss..ss..........ssssssssss..ss...ss..ss..ss..ss..ss 1255s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_cat.py .......s.s...s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s...................................... 1255s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_extract.py ..ss..ss....ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ssssss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss...ss..ss..ss..ss....ssss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ssssss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss....ssss..ss..ss................ssssssssssssssss..ss..ss...ss..sss 1256s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_find_replace.py ..ss..............ssssssssssss..ss..ss...........................sss...........................sss..ss..ss...ss........................ssssssssssssssssssssssss..ss......ssssss..ss..ss...ss..ss..ss....ssss..ss..ss..ss..ss..ss....ssss..ss...ss..ss..ss..ss..ss..ss..ss...ss..ss..ss.s.sssss.s.sssss...ss 1256s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_get_dummies.py ..ss...ss. 1256s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_split_partition.py ....ssss....ssss..ss..ss..ss............ssssssss..ss..ss..ss..ss....ssss............ssssssssssss....ssss..ss..ss..ss..ss.....ss..ss..ss.....ss..ss.....ssss....ssss....ssss....ssss....ssss......ssss....ssss..ss..ss......ssss...........ss 1257s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_string_array.py ...............................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....ssss....ssss.s 1257s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_strings.py ......ss...ss.....ssss..ss................ssssssssssssssss....ssss....ssss..ss...ss.............ssssssssssss............ssssssssssss..ss..ss....ssss....ssss....ssss..ss..........ssssssssss..................ssssssssssssssss......ssssss.........ssssss....ssss....ssss..ss...ss..ss..ss.....ssss..ss....................ss....... 1257s 1257s =============================== warnings summary =============================== 1257s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1257s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-yxba8k7b' 1257s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1257s 1257s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1257s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-ojrzju3z' 1257s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1257s 1257s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1257s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1257s ============================= slowest 30 durations ============================= 1257s 0.06s setup tests/strings/test_strings.py::test_count_mixed_object 1257s 0.02s call tests/strings/test_strings.py::test_empty_str_methods[string[python]] 1257s 0.02s teardown tests/strings/test_strings.py::test_series_str_decode 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data7-names7] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data5-names5] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data6-names6] 1257s 0.01s call tests/strings/test_strings.py::test_empty_str_methods[object] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data3-names3] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data2-names2] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data7-names7] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data5-names5] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data6-names6] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data1-names1] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data0-names0] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data2-names2] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data4-names4] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data3-names3] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract_subject_index[string[python]] 1257s 0.01s call tests/strings/test_extract.py::test_extract_expand_capture_groups[string[python]] 1257s 0.01s call tests/strings/test_extract.py::test_extractall[string[python]] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data0-names0] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract_subject_index[object] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data1-names1] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data4-names4] 1257s 0.01s call tests/strings/test_extract.py::test_extract_expand_capture_groups[object] 1257s 0.01s call tests/strings/test_extract.py::test_extractall[object] 1257s 0.01s call tests/strings/test_cat.py::test_str_cat_mixed_inputs[index] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract[string[python]] 1257s 0.01s call tests/strings/test_cat.py::test_str_cat_mixed_inputs[series] 1257s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract[object] 1257s ========== 2704 passed, 887 skipped, 13 xfailed, 2 warnings in 9.32s =========== 1258s + echo 'rdjoqkol test state = true' 1258s + for TEST_SUBSET in $modpath/tests/* 1258s rdjoqkol test state = true 1258s + echo /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 1258s + grep -q -e __pycache__ 1258s + PANDAS_CI=1 1258s + LC_ALL=C.UTF-8 1258s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 1259s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1259s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1259s 1259s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1259s ============================= test session starts ============================== 1259s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1259s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1259s rootdir: /usr/lib/python3/dist-packages/pandas 1259s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1259s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1259s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1259s collected 8 items 1259s 1259s ../../../usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py ........ 1259s 1259s =============================== warnings summary =============================== 1259s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1259s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-0m7k9q6_' 1259s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1259s 1259s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1259s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-yxh9w6dm' 1259s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1259s 1259s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1259s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1259s ============================= slowest 30 durations ============================= 1259s 1259s (24 durations < 0.005s hidden. Use -vv to show these durations.) 1259s ======================== 8 passed, 2 warnings in 0.18s ========================= 1259s + echo 'rdjoqkol test state = true' 1259s + for TEST_SUBSET in $modpath/tests/* 1259s + echo /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 1259s + grep -q -e __pycache__ 1259s + PANDAS_CI=1 1259s + LC_ALL=C.UTF-8 1259s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 1259s rdjoqkol test state = true 1260s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1260s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1260s 1260s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1260s ============================= test session starts ============================== 1260s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1260s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1260s rootdir: /usr/lib/python3/dist-packages/pandas 1260s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1260s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1260s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1260s collected 471 items 1260s 1264s ../../../usr/lib/python3/dist-packages/pandas/tests/test_algos.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1264s 1264s =============================== warnings summary =============================== 1264s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1264s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-dsqj7whw' 1264s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1264s 1264s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1264s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-y8fzbnmk' 1264s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1264s 1264s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1264s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1264s ============================= slowest 30 durations ============================= 1264s 1.70s call tests/test_algos.py::TestRank::test_pct_max_many_rows 1264s 0.44s call tests/test_algos.py::TestRank::test_scipy_compat[arr0] 1264s 0.03s call tests/test_algos.py::TestUnique::test_object_refcount_bug 1264s 0.02s call tests/test_algos.py::TestDuplicated::test_datetime_likes 1264s 0.01s call tests/test_algos.py::TestIsin::test_large 1264s 0.01s call tests/test_algos.py::TestIsin::test_same_nan_is_in_large_series 1264s 0.01s call tests/test_algos.py::TestValueCounts::test_value_counts_bins 1264s 0.01s call tests/test_algos.py::TestFactorize::test_factorize_interval_non_nano[s] 1264s 0.01s call tests/test_algos.py::TestValueCounts::test_categorical_nans 1264s 1264s (21 durations < 0.005s hidden. Use -vv to show these durations.) 1264s ======================= 471 passed, 2 warnings in 3.54s ======================== 1264s rdjoqkol test state = true 1264s + echo 'rdjoqkol test state = true' 1264s + for TEST_SUBSET in $modpath/tests/* 1264s + echo /usr/lib/python3/dist-packages/pandas/tests/test_common.py 1264s + grep -q -e __pycache__ 1264s + PANDAS_CI=1 1264s + LC_ALL=C.UTF-8 1264s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_common.py 1265s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1265s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1265s 1265s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1265s ============================= test session starts ============================== 1265s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1265s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1265s rootdir: /usr/lib/python3/dist-packages/pandas 1265s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1265s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1265s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1265s collected 128 items 1265s 1266s ../../../usr/lib/python3/dist-packages/pandas/tests/test_common.py ...............x.x.............................................................................................................. 1266s 1266s =============================== warnings summary =============================== 1266s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1266s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-kgqszy8u' 1266s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1266s 1266s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1266s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-r7repmne' 1266s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1266s 1266s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1266s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1266s ============================= slowest 30 durations ============================= 1266s 0.57s call tests/test_common.py::test_bz2_missing_import 1266s 0.48s call tests/test_common.py::test_str_size 1266s 0.01s call tests/test_common.py::test_serializable[obj77] 1266s 1266s (27 durations < 0.005s hidden. Use -vv to show these durations.) 1266s ================== 126 passed, 2 xfailed, 2 warnings in 1.74s ================== 1267s rdjoqkol test state = true 1267s + echo 'rdjoqkol test state = true' 1267s + for TEST_SUBSET in $modpath/tests/* 1267s + echo /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 1267s + grep -q -e __pycache__ 1267s + PANDAS_CI=1 1267s + LC_ALL=C.UTF-8 1267s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 1268s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1268s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1268s 1268s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1268s ============================= test session starts ============================== 1268s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1268s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1268s rootdir: /usr/lib/python3/dist-packages/pandas 1268s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1268s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1268s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1268s collected 26 items 1268s 1273s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sx.........s. 1273s 1273s =============================== warnings summary =============================== 1273s tests/test_downstream.py::test_dask 1273s /usr/lib/python3/dist-packages/dask/dataframe/__init__.py:49: FutureWarning: 1273s Dask dataframe query planning is disabled because dask-expr is not installed. 1273s 1273s You can install it with `pip install dask[dataframe]` or `conda install dask`. 1273s This will raise in a future version. 1273s 1273s warnings.warn(msg, FutureWarning) 1273s 1273s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1273s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-mb7nqyuc' 1273s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1273s 1273s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1273s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-wcxffx35' 1273s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1273s 1273s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1273s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1273s ============================= slowest 30 durations ============================= 1273s 2.41s call tests/test_downstream.py::test_oo_optimizable 1273s 2.12s call tests/test_downstream.py::test_oo_optimized_datetime_index_unpickle 1273s 0.18s call tests/test_downstream.py::test_dask 1273s 0.02s call tests/test_downstream.py::test_construct_dask_float_array_int_dtype_match_ndarray 1273s 0.02s call tests/test_downstream.py::test_yaml_dump 1273s 0.01s call tests/test_downstream.py::test_frame_setitem_dask_array_into_new_col 1273s 0.01s call tests/test_downstream.py::test_dask_ufunc 1273s 1273s (23 durations < 0.005s hidden. Use -vv to show these durations.) 1273s ============= 17 passed, 8 skipped, 1 xfailed, 3 warnings in 5.54s ============= 1273s rdjoqkol test state = true 1273s + echo 'rdjoqkol test state = true' 1273s + for TEST_SUBSET in $modpath/tests/* 1273s + echo /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 1273s + grep -q -e __pycache__ 1273s + PANDAS_CI=1 1273s + LC_ALL=C.UTF-8 1273s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 1274s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1274s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1274s 1274s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1274s ============================= test session starts ============================== 1274s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1274s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1274s rootdir: /usr/lib/python3/dist-packages/pandas 1274s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1274s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1274s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1274s collected 36 items 1274s 1275s ../../../usr/lib/python3/dist-packages/pandas/tests/test_errors.py .................................... 1275s 1275s =============================== warnings summary =============================== 1275s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1275s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-iomwvce_' 1275s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1275s 1275s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1275s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-eqvbnzgk' 1275s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1275s 1275s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1275s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1275s ============================= slowest 30 durations ============================= 1275s 1275s (30 durations < 0.005s hidden. Use -vv to show these durations.) 1275s ======================== 36 passed, 2 warnings in 0.20s ======================== 1275s rdjoqkol test state = true 1275s + echo 'rdjoqkol test state = true' 1275s + for TEST_SUBSET in $modpath/tests/* 1275s + echo /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 1275s + grep -q -e __pycache__ 1275s + PANDAS_CI=1 1275s + LC_ALL=C.UTF-8 1275s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 1275s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1275s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1275s 1275s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1276s ============================= test session starts ============================== 1276s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1276s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1276s rootdir: /usr/lib/python3/dist-packages/pandas 1276s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1276s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1276s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1276s collected 243 items 1276s 1277s ../../../usr/lib/python3/dist-packages/pandas/tests/test_expressions.py ................................................................................................................................................................................................................................................... 1277s 1277s =============================== warnings summary =============================== 1277s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1277s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-0oqv6y35' 1277s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1277s 1277s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1277s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-oupt_nd2' 1277s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1277s 1277s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1277s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1277s ============================= slowest 30 durations ============================= 1277s 0.02s call tests/test_expressions.py::TestExpressions::test_invalid 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_integer_integers] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[gt-False-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_integer] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_frame] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_frame] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ge-False-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-False-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[add-True-_integer] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-True-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-True-_frame] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-False-_integer] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[add-False-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_integer_integers] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-True-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-True-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-True-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[eq-True-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-False-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-False-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-False-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_integer] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-False-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[eq-False-_integer] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-True-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ge-True-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[sub-True-_mixed] 1277s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[gt-True-_mixed] 1277s ======================= 243 passed, 2 warnings in 1.67s ======================== 1277s rdjoqkol test state = true 1277s + echo 'rdjoqkol test state = true' 1277s + for TEST_SUBSET in $modpath/tests/* 1277s + echo /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 1277s + grep -q -e __pycache__ 1277s + PANDAS_CI=1 1277s + LC_ALL=C.UTF-8 1277s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 1278s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1278s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1278s 1278s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1278s ============================= test session starts ============================== 1278s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1278s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1278s rootdir: /usr/lib/python3/dist-packages/pandas 1278s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1278s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1278s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1278s collected 5 items 1278s 1278s ../../../usr/lib/python3/dist-packages/pandas/tests/test_flags.py ..... 1278s 1278s =============================== warnings summary =============================== 1278s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1278s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-iqkrpcv8' 1278s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1278s 1278s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1278s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-mudh7296' 1278s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1278s 1278s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1278s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1278s ============================= slowest 30 durations ============================= 1278s 1278s (15 durations < 0.005s hidden. Use -vv to show these durations.) 1278s ======================== 5 passed, 2 warnings in 0.15s ========================= 1278s rdjoqkol test state = true 1278s + echo 'rdjoqkol test state = true' 1278s + for TEST_SUBSET in $modpath/tests/* 1278s + echo /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 1278s + grep -q -e __pycache__ 1278s + PANDAS_CI=1 1278s + LC_ALL=C.UTF-8 1278s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 1279s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1279s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1279s 1279s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1280s ============================= test session starts ============================== 1280s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1280s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1280s rootdir: /usr/lib/python3/dist-packages/pandas 1280s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1280s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1280s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1280s collected 19 items 1280s 1280s ../../../usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py ................... 1280s 1280s =============================== warnings summary =============================== 1280s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1280s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-usu8fe5k' 1280s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1280s 1280s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1280s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-wd0exn1y' 1280s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1280s 1280s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1280s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1280s ============================= slowest 30 durations ============================= 1280s 0.03s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level 1280s 0.01s setup tests/test_multilevel.py::TestMultiLevel::test_reindex_level 1280s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level_partial_selection 1280s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_alignment 1280s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_level_with_tuples 1280s 0.01s setup tests/test_multilevel.py::TestMultiLevel::test_groupby_multilevel 1280s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_groupby_multilevel 1280s 0.01s setup tests/test_multilevel.py::TestMultiLevel::test_reindex_preserve_levels 1280s 0.01s setup tests/test_multilevel.py::TestMultiLevel::test_setitem_with_expansion_multiindex_columns 1280s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_multiindex_with_na 1280s 1280s (20 durations < 0.005s hidden. Use -vv to show these durations.) 1280s ======================== 19 passed, 2 warnings in 0.43s ======================== 1280s rdjoqkol test state = true 1280s + echo 'rdjoqkol test state = true' 1280s + for TEST_SUBSET in $modpath/tests/* 1280s + echo /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 1280s + grep -q -e __pycache__ 1280s + PANDAS_CI=1 1280s + LC_ALL=C.UTF-8 1280s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 1281s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1281s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1281s 1281s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1281s ============================= test session starts ============================== 1281s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1281s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1281s rootdir: /usr/lib/python3/dist-packages/pandas 1281s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1281s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1281s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1281s collected 245 items 1281s 1282s ../../../usr/lib/python3/dist-packages/pandas/tests/test_nanops.py ..................................................................................................................................................................................................................................................... 1282s 1282s =============================== warnings summary =============================== 1282s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1282s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-55m2u1pc' 1282s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1282s 1282s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1282s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-vvnvxomh' 1282s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1282s 1282s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1282s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1282s ============================= slowest 30 durations ============================= 1282s 0.41s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-0] 1282s 0.03s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-2] 1282s 0.03s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-1] 1282s 0.03s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[True] 1282s 0.03s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[True] 1282s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[True] 1282s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[False] 1282s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-1] 1282s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[False] 1282s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-2] 1282s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-0] 1282s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nancorr_spearman 1282s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[False] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanops_with_warnings[True-reduction-max] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-1] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-0] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansum[True] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-0] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-2] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanops_with_warnings[True-reduction-min] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-1] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-2] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmean[True] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanargmax[True] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanargmin[True] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanprod[True] 1282s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nan_funcs[True-nanany-any] 1282s 1282s (3 durations < 0.005s hidden. Use -vv to show these durations.) 1282s ======================= 245 passed, 2 warnings in 1.59s ======================== 1283s rdjoqkol test state = true 1283s + echo 'rdjoqkol test state = true' 1283s + for TEST_SUBSET in $modpath/tests/* 1283s + echo /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 1283s + grep -q -e __pycache__ 1283s + PANDAS_CI=1 1283s + LC_ALL=C.UTF-8 1283s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 1283s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1283s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1283s 1283s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1284s ============================= test session starts ============================== 1284s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1284s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1284s rootdir: /usr/lib/python3/dist-packages/pandas 1284s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1284s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1284s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1284s collected 5 items 1284s 1284s ../../../usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py ..... 1284s 1284s =============================== warnings summary =============================== 1284s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1284s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-bnlae4ex' 1284s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1284s 1284s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1284s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-9pjq9z4z' 1284s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1284s 1284s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1284s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1284s ============================= slowest 30 durations ============================= 1284s 0.01s call tests/test_optional_dependency.py::test_xlrd_version_fallback 1284s 1284s (14 durations < 0.005s hidden. Use -vv to show these durations.) 1284s ======================== 5 passed, 2 warnings in 0.26s ========================= 1284s + echo 'rdjoqkol test state = true' 1284s + for TEST_SUBSET in $modpath/tests/* 1284s + echo /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 1284s + grep -q -e __pycache__ 1284s rdjoqkol test state = true 1284s + PANDAS_CI=1 1284s + LC_ALL=C.UTF-8 1284s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 1285s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1285s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1285s 1285s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1285s ============================= test session starts ============================== 1285s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1285s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1285s rootdir: /usr/lib/python3/dist-packages/pandas 1285s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1285s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1285s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1285s collected 7 items 1285s 1285s ../../../usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py ....... 1285s 1285s =============================== warnings summary =============================== 1285s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1285s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-jubo38j5' 1285s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1285s 1285s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1285s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-l0nwqms3' 1285s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1285s 1285s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1285s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1285s ============================= slowest 30 durations ============================= 1285s 1285s (21 durations < 0.005s hidden. Use -vv to show these durations.) 1285s ======================== 7 passed, 2 warnings in 0.16s ========================= 1285s rdjoqkol test state = true 1285s + echo 'rdjoqkol test state = true' 1285s + for TEST_SUBSET in $modpath/tests/* 1285s + echo /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 1285s + grep -q -e __pycache__ 1285s + PANDAS_CI=1 1285s + LC_ALL=C.UTF-8 1285s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 1286s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1286s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1286s 1286s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1286s ============================= test session starts ============================== 1286s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1286s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1286s rootdir: /usr/lib/python3/dist-packages/pandas 1286s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1286s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1286s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1286s collected 54 items / 15 deselected / 39 selected 1286s 1288s ../../../usr/lib/python3/dist-packages/pandas/tests/test_sorting.py ....................................... 1288s 1288s =============================== warnings summary =============================== 1288s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1288s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-2tlviyy0' 1288s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1288s 1288s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1288s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-bjlbcx3y' 1288s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1288s 1288s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1288s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1288s ============================= slowest 30 durations ============================= 1288s 1.35s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_range 1288s 0.48s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[mean] 1288s 0.48s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[median] 1288s 0.01s call tests/test_sorting.py::TestMerge::test_int64_overflow_outer_merge 1288s 1288s (26 durations < 0.005s hidden. Use -vv to show these durations.) 1288s ================ 39 passed, 15 deselected, 2 warnings in 2.60s ================= 1289s rdjoqkol test state = true 1289s + echo 'rdjoqkol test state = true' 1289s + for TEST_SUBSET in $modpath/tests/* 1289s + echo /usr/lib/python3/dist-packages/pandas/tests/test_take.py 1289s + grep -q -e __pycache__ 1289s + PANDAS_CI=1 1289s + LC_ALL=C.UTF-8 1289s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_take.py 1290s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1290s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1290s 1290s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1290s ============================= test session starts ============================== 1290s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1290s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1290s rootdir: /usr/lib/python3/dist-packages/pandas 1290s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1290s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1290s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1290s collected 81 items 1290s 1290s ../../../usr/lib/python3/dist-packages/pandas/tests/test_take.py ................................................................................. 1290s 1290s =============================== warnings summary =============================== 1290s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1290s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-y3czn2jg' 1290s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1290s 1290s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1290s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-kez1rdbj' 1290s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1290s 1290s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1290s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1290s ============================= slowest 30 durations ============================= 1290s 1290s (30 durations < 0.005s hidden. Use -vv to show these durations.) 1290s ======================== 81 passed, 2 warnings in 0.50s ======================== 1290s + echo 'rdjoqkol test state = true' 1290s + for TEST_SUBSET in $modpath/tests/* 1290s rdjoqkol test state = true 1290s + echo /usr/lib/python3/dist-packages/pandas/tests/tools 1290s + grep -q -e __pycache__ 1290s + PANDAS_CI=1 1290s + LC_ALL=C.UTF-8 1290s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tools 1291s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1291s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1291s 1291s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1292s ============================= test session starts ============================== 1292s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1292s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1292s rootdir: /usr/lib/python3/dist-packages/pandas 1292s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1292s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1292s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1292s collected 1510 items 1292s 1296s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss....................................................................ss................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 1297s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_numeric.py ...s.s....................................................................................................................................................................................................................................................xx.......................................................................................................................ssssss.s.s.................................sss...sss.s....ssss.s.s 1297s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_time.py ........... 1297s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_timedelta.py ........................................................................ssssssssssss 1297s 1297s =============================== warnings summary =============================== 1297s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1297s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-t_cgcsrj' 1297s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1297s 1297s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1297s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-_jmjqd0w' 1297s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1297s 1297s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1297s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1297s ============================= slowest 30 durations ============================= 1297s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-None] 1297s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-True] 1297s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-True] 1297s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-None] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-True] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-None] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-True] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-None] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-None] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-None] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-True] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-None] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-True] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-None] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-True] 1297s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-True] 1297s 0.05s call tests/tools/test_to_datetime.py::TestTimeConversionFormats::test_to_datetime_parse_tzname_or_tzoffset[%Y-%m-%d %H:%M:%S %Z-dates0-expected_dates0] 1297s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-True] 1297s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-True] 1297s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-None] 1297s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-None] 1297s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-None] 1297s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-True] 1297s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-True] 1297s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-None] 1297s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_fixed_offset 1297s 0.02s call tests/tools/test_to_datetime.py::TestToDatetimeMisc::test_to_datetime_timezone_name 1297s 0.01s teardown tests/tools/test_to_timedelta.py::test_from_timedelta_arrow_dtype[ms] 1297s 0.01s call tests/tools/test_to_datetime.py::TestToDatetimeDataFrame::test_dataframe[True] 1297s 0.01s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_array_of_dt64s[True-s] 1297s =========== 1451 passed, 55 skipped, 4 xfailed, 2 warnings in 5.84s ============ 1297s rdjoqkol test state = true 1297s + echo 'rdjoqkol test state = true' 1297s + for TEST_SUBSET in $modpath/tests/* 1297s + echo /usr/lib/python3/dist-packages/pandas/tests/tseries 1297s + grep -q -e __pycache__ 1297s + PANDAS_CI=1 1297s + LC_ALL=C.UTF-8 1297s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tseries 1298s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1298s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1298s 1298s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1300s ============================= test session starts ============================== 1300s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1300s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1300s rootdir: /usr/lib/python3/dist-packages/pandas 1300s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1300s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1300s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1300s collected 5480 items 1300s 1300s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_freq_code.py ................... 1300s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_frequencies.py .......... 1303s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_inference.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1303s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_calendar.py ........ 1303s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_federal.py ... 1303s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_holiday.py ................................................. 1303s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_observance.py ................................. 1303s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_day.py ....................... 1303s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_hour.py .............................................................................................. 1304s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_month.py ..................... 1304s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_quarter.py .............................................. 1304s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_year.py ................... 1305s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_common.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1305s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_day.py ....... 1305s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_hour.py ............................ 1305s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_month.py .................................................... 1305s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_dst.py .......................... 1305s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_easter.py .......... 1306s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_fiscal.py ............................................................................................................................................. 1307s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_index.py ........................ 1307s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_month.py ............................................................ 1313s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..................................................................................................................................................................................................................................................x................................................................................................................................................................................................................................................ 1314s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets_properties.py .. 1314s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_quarter.py ........................................................................................ 1317s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_ticks.py ............................................................................................................ 1317s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_week.py .............................................. 1317s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_year.py ................................. 1317s 1317s =============================== warnings summary =============================== 1317s tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 1317s /usr/lib/python3/dist-packages/dateutil/zoneinfo/__init__.py:26: UserWarning: I/O error(2): No such file or directory 1317s warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) 1317s 1317s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1317s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-lz0lm5ar' 1317s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1317s 1317s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1317s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-uueh7djc' 1317s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1317s 1317s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1317s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1317s ============================= slowest 30 durations ============================= 1317s 0.56s call tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 1317s 0.33s call tests/tseries/offsets/test_offsets_properties.py::test_shift_across_dst 1317s 0.29s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Second] 1317s 0.29s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Nano] 1317s 0.29s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Milli] 1317s 0.28s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Micro] 1317s 0.26s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Minute] 1317s 0.25s call tests/tseries/offsets/test_custom_business_day.py::TestCustomBusinessDay::test_calendar 1317s 0.23s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Hour] 1317s 0.22s call tests/tseries/offsets/test_custom_business_hour.py::TestCustomBusinessHour::test_us_federal_holiday_with_datetime 1317s 0.20s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Micro] 1317s 0.11s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Nano] 1317s 0.10s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Minute] 1317s 0.10s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Milli] 1317s 0.09s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Second] 1317s 0.09s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Hour] 1317s 0.09s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthBegin--2] 1317s 0.08s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthBegin--2] 1317s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[MonthBegin--2] 1317s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[BYearEnd--2] 1317s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterBegin--2] 1317s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[YearEnd--2] 1317s 0.07s call tests/tseries/offsets/test_index.py::test_apply_index[BYearBegin--2] 1317s 0.06s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterEnd--2] 1317s 0.06s call tests/tseries/offsets/test_index.py::test_apply_index[QuarterBegin--2] 1317s 0.06s call tests/tseries/offsets/test_index.py::test_apply_index[YearBegin--2] 1317s 0.06s call tests/tseries/offsets/test_index.py::test_apply_index[QuarterEnd--2] 1317s 0.06s teardown tests/tseries/offsets/test_year.py::test_add_out_of_pydatetime_range 1317s 0.05s call tests/tseries/offsets/test_common.py::test_apply_out_of_range[tzlocal()-YearEnd] 1317s 0.05s call tests/tseries/offsets/test_fiscal.py::TestFY5253LastOfMonthQuarter::test_offset 1317s ================= 5478 passed, 2 xfailed, 3 warnings in 18.49s ================= 1318s rdjoqkol test state = true 1318s + echo 'rdjoqkol test state = true' 1318s + for TEST_SUBSET in $modpath/tests/* 1318s + echo /usr/lib/python3/dist-packages/pandas/tests/tslibs 1318s + grep -q -e __pycache__ 1318s + PANDAS_CI=1 1318s + LC_ALL=C.UTF-8 1318s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tslibs 1319s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1319s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1319s 1319s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1320s ============================= test session starts ============================== 1320s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1320s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1320s rootdir: /usr/lib/python3/dist-packages/pandas 1320s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1320s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1320s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1320s collected 1140 items 1320s 1320s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_api.py . 1320s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_array_to_datetime.py ............................................ 1320s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_ccalendar.py ................. 1326s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_conversion.py ...................................................................... 1326s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_fields.py .... 1326s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_libfrequencies.py ............ 1326s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_liboffsets.py .......................................................................... 1326s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_np_datetime.py ........ 1326s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_npy_units.py .. 1326s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parse_iso8601.py ................................................... 1334s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parsing.py .............................................................................................................................................x...x................................. 1334s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_period.py ....................................... 1334s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_resolution.py ................... 1334s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_strptime.py ....... 1334s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timedeltas.py ......................... 1335s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timezones.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1335s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_to_offset.py ................................................................................................... 1335s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_tzconversion.py . 1335s 1335s =============================== warnings summary =============================== 1335s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1335s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-rb07t21t' 1335s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1335s 1335s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1335s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-udak10a0' 1335s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1335s 1335s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1335s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1335s ============================= slowest 30 durations ============================= 1335s 0.86s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['dateutil/Asia/Singapore'] 1335s 0.51s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-True-.] 1335s 0.48s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['+01:15'] 1335s 0.44s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[tzlocal()] 1335s 0.43s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['Asia/Tokyo'] 1335s 0.41s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC-02:15'] 1335s 0.40s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(300)] 1335s 0.39s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC+01:15'] 1335s 0.38s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['-02:15'] 1335s 0.37s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(days=-1, seconds=82800), 'foo')] 1335s 0.37s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(seconds=3600))] 1335s 0.36s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(-300)] 1335s 0.35s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-False-.] 1335s 0.20s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %d %Y-False- ] 1335s 0.18s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True-/] 1335s 0.16s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-False- ] 1335s 0.16s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC'] 1335s 0.14s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-False--] 1335s 0.14s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True- ] 1335s 0.14s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True--] 1335s 0.13s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-True-/] 1335s 0.13s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True- ] 1335s 0.13s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False- ] 1335s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True-.] 1335s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %d %Y-False--] 1335s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %d %Y-True-/] 1335s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True-/] 1335s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True-.] 1335s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False--] 1335s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False-/] 1335s ================= 1138 passed, 2 xfailed, 2 warnings in 16.36s ================= 1335s + echo 'rdjoqkol test state = true' 1335s + for TEST_SUBSET in $modpath/tests/* 1335s + echo /usr/lib/python3/dist-packages/pandas/tests/util 1335s + grep -q -e __pycache__ 1335s rdjoqkol test state = true 1335s + PANDAS_CI=1 1335s + LC_ALL=C.UTF-8 1335s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/util 1336s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1336s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1336s 1336s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1337s ============================= test session starts ============================== 1337s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1337s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1337s rootdir: /usr/lib/python3/dist-packages/pandas 1337s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1337s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1337s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1337s collected 916 items 1337s 1337s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_almost_equal.py .................................................................................................................................................................... 1337s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_attr_equal.py .......................................... 1337s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_categorical_equal.py .......... 1337s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_extension_array_equal.py ..................... 1338s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_frame_equal.py ............................................................................................................... 1338s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_index_equal.py ................................................................ 1338s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_interval_array_equal.py ....... 1338s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_numpy_array_equal.py ......................... 1338s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_produces_warning.py ............................................................................................................................ 1338s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_series_equal.py .............................................................................................. 1338s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate.py ... 1338s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_kwarg.py .............. 1338s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_nonkeyword_arguments.py ................... 1338s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_doc.py .... 1339s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_hashing.py ..................................................................................................................................................... 1339s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 1339s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_rewrite_warning.py .......... 1339s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_shares_memory.py .s 1339s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_show_versions.py .... 1339s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_util.py ...sx.. 1339s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args.py ...... 1339s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args_and_kwargs.py ...... 1340s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_inclusive.py ........... 1340s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_kwargs.py .................. 1340s 1340s =============================== warnings summary =============================== 1340s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1340s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-zybe7ulr' 1340s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1340s 1340s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1340s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-j3l0h4am' 1340s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1340s 1340s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1340s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1340s ============================= slowest 30 durations ============================= 1340s 0.79s call tests/util/test_show_versions.py::test_show_versions 1340s 0.02s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-7] 1340s 0.02s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-7] 1340s 0.01s call tests/util/test_show_versions.py::test_show_versions_console_json 1340s 0.01s call tests/util/test_show_versions.py::test_json_output_match 1340s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-6] 1340s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-6] 1340s 0.01s teardown tests/util/test_validate_kwargs.py::test_validate_bool_kwarg[None-copy] 1340s 1340s (22 durations < 0.005s hidden. Use -vv to show these durations.) 1340s ============ 913 passed, 2 skipped, 1 xfailed, 2 warnings in 3.18s ============= 1340s rdjoqkol test state = true 1340s + echo 'rdjoqkol test state = true' 1340s + for TEST_SUBSET in $modpath/tests/* 1340s + echo /usr/lib/python3/dist-packages/pandas/tests/window 1340s + grep -q -e __pycache__ 1340s + PANDAS_CI=1 1340s + LC_ALL=C.UTF-8 1340s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.ET1XN8/build.OCi/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/window 1341s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1341s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1341s 1341s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1343s ============================= test session starts ============================== 1343s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1343s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1343s rootdir: /usr/lib/python3/dist-packages/pandas 1343s configfile: ../../../../../tmp/autopkgtest.ET1XN8/build.OCi/src/pyproject.toml 1343s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1343s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1343s collected 10242 items / 536 deselected / 1 skipped / 9706 selected 1343s 1347s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1348s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_expanding.py ........x.......................x..x..x..x..x..x....................x.......................x..x..x..x..x..x................................................................................................................................................................................................................................................................................ 1350s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_rolling.py ..............x..x............................................x..x..x..x..x..x..x..x..x..x..x..x......................................x..x............................................x..x..x..x..x..x..x..x..x..x..x..x................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1353s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1354s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 1355s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 1355s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 1361s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1362s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 1363s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 1364s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 1365s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1370s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 1373s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py .........................................................................................................................................................................................................................................................................................................................................................................................xxxx........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1376s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 1378s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 1378s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 1378s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 1379s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 1379s 1379s =============================== warnings summary =============================== 1379s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1379s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-ltmipohq' 1379s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1379s 1379s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1379s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-2l1243xa' 1379s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1379s 1379s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1379s -- generated xml file: /tmp/autopkgtest.ET1XN8/autopkgtest_tmp/test-data.xml --- 1379s ============================= slowest 30 durations ============================= 1379s 0.45s call tests/window/test_rolling_functions.py::test_rolling_functions_window_non_shrinkage[14] 1379s 0.23s call tests/window/test_apply.py::test_time_rule_frame[False] 1379s 0.15s call tests/window/test_apply.py::test_frame[False] 1379s 0.14s teardown tests/window/test_numba.py::TestEngine::test_dont_cache_args[False-True-True-table-expanding-window_kwargs1] 1379s 0.10s teardown tests/window/test_win_type.py::test_rolling_center_axis_1 1379s 0.09s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[corr] 1379s 0.08s call tests/window/test_expanding.py::test_expanding_corr_pairwise 1379s 0.08s call tests/window/test_expanding.py::test_expanding_cov_pairwise 1379s 0.07s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[cov] 1379s 0.07s call tests/window/test_pairwise.py::test_flex_binary_frame[corr] 1379s 0.06s call tests/window/test_pairwise.py::test_flex_binary_frame[cov] 1379s 0.05s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_self[pairwise_frames0-3] 1379s 0.05s call tests/window/test_apply.py::test_center_reindex_frame[False] 1379s 0.05s call tests/window/test_apply.py::test_min_periods[False-None-0] 1379s 0.05s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_self[pairwise_frames1-3] 1379s 0.05s call tests/window/test_apply.py::test_min_periods[False-1-0] 1379s 0.05s call tests/window/test_apply.py::test_center_reindex_series[False] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames2-0] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames4-3] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames3-1] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames5-3] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_self[pairwise_frames1-2] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames4-0] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames4-2] 1379s 0.04s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[corr] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames4-1] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames2-1] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames2-5] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames3-3] 1379s 0.04s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames5-1] 1379s == 9010 passed, 650 skipped, 536 deselected, 47 xfailed, 2 warnings in 38.58s == 1380s rdjoqkol test state = true 1380s + echo 'rdjoqkol test state = true' 1380s + true 1380s autopkgtest [17:46:36]: test unittests3: -----------------------] 1381s unittests3 PASS 1381s autopkgtest [17:46:37]: test unittests3: - - - - - - - - - - results - - - - - - - - - - 1381s autopkgtest [17:46:37]: test ignoredtests: preparing testbed 1382s Reading package lists... 1382s Building dependency tree... 1382s Reading state information... 1382s Starting pkgProblemResolver with broken count: 0 1382s Starting 2 pkgProblemResolver with broken count: 0 1382s Done 1382s The following NEW packages will be installed: 1382s libpq5 python3-psycopg2 python3-pymysql 1383s 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. 1383s Need to get 365 kB of archives. 1383s After this operation, 1367 kB of additional disk space will be used. 1383s Get:1 http://ftpmaster.internal/ubuntu questing/main ppc64el libpq5 ppc64el 17.4-1 [174 kB] 1383s Get:2 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-psycopg2 ppc64el 2.9.10-1build1 [151 kB] 1383s Get:3 http://ftpmaster.internal/ubuntu questing/main ppc64el python3-pymysql all 1.1.1-2ubuntu1 [39.5 kB] 1383s Fetched 365 kB in 0s (843 kB/s) 1383s Selecting previously unselected package libpq5:ppc64el. 1383s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 131177 files and directories currently installed.) 1383s Preparing to unpack .../libpq5_17.4-1_ppc64el.deb ... 1383s Unpacking libpq5:ppc64el (17.4-1) ... 1383s Selecting previously unselected package python3-psycopg2. 1383s Preparing to unpack .../python3-psycopg2_2.9.10-1build1_ppc64el.deb ... 1383s Unpacking python3-psycopg2 (2.9.10-1build1) ... 1383s Selecting previously unselected package python3-pymysql. 1383s Preparing to unpack .../python3-pymysql_1.1.1-2ubuntu1_all.deb ... 1383s Unpacking python3-pymysql (1.1.1-2ubuntu1) ... 1383s Setting up libpq5:ppc64el (17.4-1) ... 1383s Setting up python3-psycopg2 (2.9.10-1build1) ... 1384s Setting up python3-pymysql (1.1.1-2ubuntu1) ... 1384s Processing triggers for libc-bin (2.41-6ubuntu1) ... 1385s autopkgtest [17:46:41]: test ignoredtests: [----------------------- 1385s === python3.13 === 1385s tests that use numba (may crash on non-x86) - checked with grep -rl -e numba pandas/tests - -m not slow because there are enough to time out otherwise 1386s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1386s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1386s 1386s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1388s ============================= test session starts ============================== 1388s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1388s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1388s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1388s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1388s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1388s collected 10446 items / 536 deselected / 2 skipped / 9910 selected 1388s 1391s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 1392s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 1393s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1394s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1394s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 1415s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1422s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_expanding.py ........x.......................x..x..x..x..x..x....................x.......................x..x..x..x..x..x................................................................................................................................................................................................................................................................................ 1437s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_rolling.py ..............x..x............................................x..x..x..x..x..x..x..x..x..x..x..x......................................x..x............................................x..x..x..x..x..x..x..x..x..x..x..x................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1452s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1454s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 1459s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 1460s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 1504s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1509s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 1516s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 1519s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 1525s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1534s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 1552s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py .........................................................................................................................................................................................................................................................................................................................................................................................xxxx........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1562s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 1566s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 1573s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 1575s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 1696s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 1696s 1696s =============================== warnings summary =============================== 1696s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1696s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1696s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1696s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1696s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1696s /usr/lib/python3/dist-packages/pandas/compat/_optional.py:130: UserWarning: Non-x86 system detected, Numba may give wrong results or crash 1696s warnings.warn(warn_numba_platform) 1696s 1696s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numba.py:11 1696s /usr/lib/python3/dist-packages/pandas/tests/groupby/test_numba.py:11: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1696s pytestmark = pytest.mark.single_cpu 1696s 1696s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py:944 1696s /usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py:944: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1696s @pytest.mark.single_cpu 1696s 1696s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py:14 1696s /usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py:14: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1696s pytestmark = pytest.mark.single_cpu 1696s 1696s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:22 1696s /usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:22: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1696s pytestmark = pytest.mark.single_cpu 1696s 1696s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:230 1696s /usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:230: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1696s @pytest.mark.single_cpu 1696s 1696s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:21 1696s /usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:21: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1696s pytestmark = pytest.mark.single_cpu 1696s 1696s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:326 1696s /usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:326: PytestUnknownMarkWarning: Unknown pytest.mark.slow - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1696s @pytest.mark.slow 1696s 1696s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_online.py:11 1696s /usr/lib/python3/dist-packages/pandas/tests/window/test_online.py:11: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1696s pytestmark = pytest.mark.single_cpu 1696s 1696s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py:155 1696s /usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py:155: PytestUnknownMarkWarning: Unknown pytest.mark.slow - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1696s @pytest.mark.slow 1696s 1696s frame/test_ufunc.py: 32 warnings 1696s groupby/test_timegrouper.py: 31 warnings 1696s groupby/transform/test_numba.py: 53 warnings 1696s groupby/aggregate/test_numba.py: 35 warnings 1696s util/test_numba.py: 1 warning 1696s window/moments/test_moments_consistency_ewm.py: 1088 warnings 1696s window/moments/test_moments_consistency_expanding.py: 380 warnings 1696s window/moments/test_moments_consistency_rolling.py: 760 warnings 1696s window/test_api.py: 937 warnings 1696s window/test_apply.py: 82 warnings 1696s window/test_base_indexer.py: 228 warnings 1696s window/test_cython_aggregations.py: 72 warnings 1696s window/test_dtypes.py: 2580 warnings 1696s window/test_ewm.py: 283 warnings 1696s window/test_expanding.py: 333 warnings 1696s window/test_groupby.py: 115 warnings 1696s window/test_numba.py: 51 warnings 1696s window/test_pairwise.py: 312 warnings 1696s window/test_rolling.py: 888 warnings 1696s window/test_rolling_functions.py: 418 warnings 1696s window/test_rolling_quantile.py: 186 warnings 1696s window/test_rolling_skew_kurt.py: 68 warnings 1696s window/test_timeseries_window.py: 83 warnings 1696s window/test_win_type.py: 287 warnings 1696s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=7361) is multi-threaded, use of fork() may lead to deadlocks in the child. 1696s pid = os.fork() 1696s 1696s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1696s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-8wzpzkbj' 1696s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1696s 1696s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1696s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-r7b0amhe' 1696s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1696s 1696s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1696s = 9060 passed, 793 skipped, 536 deselected, 59 xfailed, 9319 warnings in 309.64s (0:05:09) = 1696s various xfailed tests - see xfail_tests_nonintel_io.patch, ignore_test_1094417_1088988.patch 1697s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1697s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1697s 1697s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1698s ============================= test session starts ============================== 1698s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1698s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1698s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1698s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1698s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1698s collected 366 items 1698s 1708s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................FFFFFFFFF................................................................................................................................... 1711s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....F................ 1715s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................F..................... 1720s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sF.........s. 1724s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py ..F.............FF..F.sFFFFFF................................. 1724s 1724s =================================== FAILURES =================================== 1724s ___________________________ test_complibs[blosc2-1] ____________________________ 1724s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-52/test_complibs_blosc2_1_0') 1724s lvl = 1, lib = 'blosc2' 1724s request = > 1724s 1724s @pytest.mark.parametrize("lvl", range(10)) 1724s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1724s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1724s @pytest.mark.skipif( 1724s not PY311 and is_ci_environment() and is_platform_linux(), 1724s reason="Segfaulting in a CI environment" 1724s # with xfail, would sometimes raise UnicodeDecodeError 1724s # invalid state byte 1724s ) 1724s def test_complibs(tmp_path, lvl, lib, request): 1724s # GH14478 1724s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1724s request.applymarker( 1724s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1724s ) 1724s df = DataFrame( 1724s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1724s ) 1724s 1724s # Remove lzo if its not available on this platform 1724s if not tables.which_lib_version("lzo"): 1724s pytest.skip("lzo not available") 1724s # Remove bzip2 if its not available on this platform 1724s if not tables.which_lib_version("bzip2"): 1724s pytest.skip("bzip2 not available") 1724s 1724s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1724s gname = f"{lvl}_{lib}" 1724s 1724s # Write and read file to see if data is consistent 1724s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1724s result = read_hdf(tmpfile, gname) 1724s tm.assert_frame_equal(result, df) 1724s 1724s # Open file and check metadata for correct amount of compression 1724s with tables.open_file(tmpfile, mode="r") as h5table: 1724s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1724s assert node.filters.complevel == lvl 1724s if lvl == 0: 1724s assert node.filters.complib is None 1724s else: 1724s > assert node.filters.complib == lib 1724s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1724s E 1724s E - blosc2 1724s E + blosc2:blosclz 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1724s ___________________________ test_complibs[blosc2-2] ____________________________ 1724s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-53/test_complibs_blosc2_2_0') 1724s lvl = 2, lib = 'blosc2' 1724s request = > 1724s 1724s @pytest.mark.parametrize("lvl", range(10)) 1724s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1724s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1724s @pytest.mark.skipif( 1724s not PY311 and is_ci_environment() and is_platform_linux(), 1724s reason="Segfaulting in a CI environment" 1724s # with xfail, would sometimes raise UnicodeDecodeError 1724s # invalid state byte 1724s ) 1724s def test_complibs(tmp_path, lvl, lib, request): 1724s # GH14478 1724s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1724s request.applymarker( 1724s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1724s ) 1724s df = DataFrame( 1724s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1724s ) 1724s 1724s # Remove lzo if its not available on this platform 1724s if not tables.which_lib_version("lzo"): 1724s pytest.skip("lzo not available") 1724s # Remove bzip2 if its not available on this platform 1724s if not tables.which_lib_version("bzip2"): 1724s pytest.skip("bzip2 not available") 1724s 1724s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1724s gname = f"{lvl}_{lib}" 1724s 1724s # Write and read file to see if data is consistent 1724s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1724s result = read_hdf(tmpfile, gname) 1724s tm.assert_frame_equal(result, df) 1724s 1724s # Open file and check metadata for correct amount of compression 1724s with tables.open_file(tmpfile, mode="r") as h5table: 1724s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1724s assert node.filters.complevel == lvl 1724s if lvl == 0: 1724s assert node.filters.complib is None 1724s else: 1724s > assert node.filters.complib == lib 1724s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1724s E 1724s E - blosc2 1724s E + blosc2:blosclz 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1724s ___________________________ test_complibs[blosc2-3] ____________________________ 1724s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-54/test_complibs_blosc2_3_0') 1724s lvl = 3, lib = 'blosc2' 1724s request = > 1724s 1724s @pytest.mark.parametrize("lvl", range(10)) 1724s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1724s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1724s @pytest.mark.skipif( 1724s not PY311 and is_ci_environment() and is_platform_linux(), 1724s reason="Segfaulting in a CI environment" 1724s # with xfail, would sometimes raise UnicodeDecodeError 1724s # invalid state byte 1724s ) 1724s def test_complibs(tmp_path, lvl, lib, request): 1724s # GH14478 1724s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1724s request.applymarker( 1724s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1724s ) 1724s df = DataFrame( 1724s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1724s ) 1724s 1724s # Remove lzo if its not available on this platform 1724s if not tables.which_lib_version("lzo"): 1724s pytest.skip("lzo not available") 1724s # Remove bzip2 if its not available on this platform 1724s if not tables.which_lib_version("bzip2"): 1724s pytest.skip("bzip2 not available") 1724s 1724s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1724s gname = f"{lvl}_{lib}" 1724s 1724s # Write and read file to see if data is consistent 1724s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1724s result = read_hdf(tmpfile, gname) 1724s tm.assert_frame_equal(result, df) 1724s 1724s # Open file and check metadata for correct amount of compression 1724s with tables.open_file(tmpfile, mode="r") as h5table: 1724s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1724s assert node.filters.complevel == lvl 1724s if lvl == 0: 1724s assert node.filters.complib is None 1724s else: 1724s > assert node.filters.complib == lib 1724s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1724s E 1724s E - blosc2 1724s E + blosc2:blosclz 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1724s ___________________________ test_complibs[blosc2-4] ____________________________ 1724s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-55/test_complibs_blosc2_4_0') 1724s lvl = 4, lib = 'blosc2' 1724s request = > 1724s 1724s @pytest.mark.parametrize("lvl", range(10)) 1724s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1724s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1724s @pytest.mark.skipif( 1724s not PY311 and is_ci_environment() and is_platform_linux(), 1724s reason="Segfaulting in a CI environment" 1724s # with xfail, would sometimes raise UnicodeDecodeError 1724s # invalid state byte 1724s ) 1724s def test_complibs(tmp_path, lvl, lib, request): 1724s # GH14478 1724s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1724s request.applymarker( 1724s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1724s ) 1724s df = DataFrame( 1724s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1724s ) 1724s 1724s # Remove lzo if its not available on this platform 1724s if not tables.which_lib_version("lzo"): 1724s pytest.skip("lzo not available") 1724s # Remove bzip2 if its not available on this platform 1724s if not tables.which_lib_version("bzip2"): 1724s pytest.skip("bzip2 not available") 1724s 1724s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1724s gname = f"{lvl}_{lib}" 1724s 1724s # Write and read file to see if data is consistent 1724s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1724s result = read_hdf(tmpfile, gname) 1724s tm.assert_frame_equal(result, df) 1724s 1724s # Open file and check metadata for correct amount of compression 1724s with tables.open_file(tmpfile, mode="r") as h5table: 1724s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1724s assert node.filters.complevel == lvl 1724s if lvl == 0: 1724s assert node.filters.complib is None 1724s else: 1724s > assert node.filters.complib == lib 1724s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1724s E 1724s E - blosc2 1724s E + blosc2:blosclz 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1724s ___________________________ test_complibs[blosc2-5] ____________________________ 1724s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-56/test_complibs_blosc2_5_0') 1724s lvl = 5, lib = 'blosc2' 1724s request = > 1724s 1724s @pytest.mark.parametrize("lvl", range(10)) 1724s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1724s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1724s @pytest.mark.skipif( 1724s not PY311 and is_ci_environment() and is_platform_linux(), 1724s reason="Segfaulting in a CI environment" 1724s # with xfail, would sometimes raise UnicodeDecodeError 1724s # invalid state byte 1724s ) 1724s def test_complibs(tmp_path, lvl, lib, request): 1724s # GH14478 1724s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1724s request.applymarker( 1724s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1724s ) 1724s df = DataFrame( 1724s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1724s ) 1724s 1724s # Remove lzo if its not available on this platform 1724s if not tables.which_lib_version("lzo"): 1724s pytest.skip("lzo not available") 1724s # Remove bzip2 if its not available on this platform 1724s if not tables.which_lib_version("bzip2"): 1724s pytest.skip("bzip2 not available") 1724s 1724s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1724s gname = f"{lvl}_{lib}" 1724s 1724s # Write and read file to see if data is consistent 1724s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1724s result = read_hdf(tmpfile, gname) 1724s tm.assert_frame_equal(result, df) 1724s 1724s # Open file and check metadata for correct amount of compression 1724s with tables.open_file(tmpfile, mode="r") as h5table: 1724s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1724s assert node.filters.complevel == lvl 1724s if lvl == 0: 1724s assert node.filters.complib is None 1724s else: 1724s > assert node.filters.complib == lib 1724s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1724s E 1724s E - blosc2 1724s E + blosc2:blosclz 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1724s ___________________________ test_complibs[blosc2-6] ____________________________ 1724s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-57/test_complibs_blosc2_6_0') 1724s lvl = 6, lib = 'blosc2' 1724s request = > 1724s 1724s @pytest.mark.parametrize("lvl", range(10)) 1724s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1724s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1724s @pytest.mark.skipif( 1724s not PY311 and is_ci_environment() and is_platform_linux(), 1724s reason="Segfaulting in a CI environment" 1724s # with xfail, would sometimes raise UnicodeDecodeError 1724s # invalid state byte 1724s ) 1724s def test_complibs(tmp_path, lvl, lib, request): 1724s # GH14478 1724s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1724s request.applymarker( 1724s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1724s ) 1724s df = DataFrame( 1724s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1724s ) 1724s 1724s # Remove lzo if its not available on this platform 1724s if not tables.which_lib_version("lzo"): 1724s pytest.skip("lzo not available") 1724s # Remove bzip2 if its not available on this platform 1724s if not tables.which_lib_version("bzip2"): 1724s pytest.skip("bzip2 not available") 1724s 1724s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1724s gname = f"{lvl}_{lib}" 1724s 1724s # Write and read file to see if data is consistent 1724s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1724s result = read_hdf(tmpfile, gname) 1724s tm.assert_frame_equal(result, df) 1724s 1724s # Open file and check metadata for correct amount of compression 1724s with tables.open_file(tmpfile, mode="r") as h5table: 1724s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1724s assert node.filters.complevel == lvl 1724s if lvl == 0: 1724s assert node.filters.complib is None 1724s else: 1724s > assert node.filters.complib == lib 1724s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1724s E 1724s E - blosc2 1724s E + blosc2:blosclz 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1724s ___________________________ test_complibs[blosc2-7] ____________________________ 1724s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-58/test_complibs_blosc2_7_0') 1724s lvl = 7, lib = 'blosc2' 1724s request = > 1724s 1724s @pytest.mark.parametrize("lvl", range(10)) 1724s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1724s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1724s @pytest.mark.skipif( 1724s not PY311 and is_ci_environment() and is_platform_linux(), 1724s reason="Segfaulting in a CI environment" 1724s # with xfail, would sometimes raise UnicodeDecodeError 1724s # invalid state byte 1724s ) 1724s def test_complibs(tmp_path, lvl, lib, request): 1724s # GH14478 1724s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1724s request.applymarker( 1724s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1724s ) 1724s df = DataFrame( 1724s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1724s ) 1724s 1724s # Remove lzo if its not available on this platform 1724s if not tables.which_lib_version("lzo"): 1724s pytest.skip("lzo not available") 1724s # Remove bzip2 if its not available on this platform 1724s if not tables.which_lib_version("bzip2"): 1724s pytest.skip("bzip2 not available") 1724s 1724s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1724s gname = f"{lvl}_{lib}" 1724s 1724s # Write and read file to see if data is consistent 1724s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1724s result = read_hdf(tmpfile, gname) 1724s tm.assert_frame_equal(result, df) 1724s 1724s # Open file and check metadata for correct amount of compression 1724s with tables.open_file(tmpfile, mode="r") as h5table: 1724s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1724s assert node.filters.complevel == lvl 1724s if lvl == 0: 1724s assert node.filters.complib is None 1724s else: 1724s > assert node.filters.complib == lib 1724s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1724s E 1724s E - blosc2 1724s E + blosc2:blosclz 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1724s ___________________________ test_complibs[blosc2-8] ____________________________ 1724s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-59/test_complibs_blosc2_8_0') 1724s lvl = 8, lib = 'blosc2' 1724s request = > 1724s 1724s @pytest.mark.parametrize("lvl", range(10)) 1724s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1724s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1724s @pytest.mark.skipif( 1724s not PY311 and is_ci_environment() and is_platform_linux(), 1724s reason="Segfaulting in a CI environment" 1724s # with xfail, would sometimes raise UnicodeDecodeError 1724s # invalid state byte 1724s ) 1724s def test_complibs(tmp_path, lvl, lib, request): 1724s # GH14478 1724s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1724s request.applymarker( 1724s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1724s ) 1724s df = DataFrame( 1724s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1724s ) 1724s 1724s # Remove lzo if its not available on this platform 1724s if not tables.which_lib_version("lzo"): 1724s pytest.skip("lzo not available") 1724s # Remove bzip2 if its not available on this platform 1724s if not tables.which_lib_version("bzip2"): 1724s pytest.skip("bzip2 not available") 1724s 1724s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1724s gname = f"{lvl}_{lib}" 1724s 1724s # Write and read file to see if data is consistent 1724s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1724s result = read_hdf(tmpfile, gname) 1724s tm.assert_frame_equal(result, df) 1724s 1724s # Open file and check metadata for correct amount of compression 1724s with tables.open_file(tmpfile, mode="r") as h5table: 1724s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1724s assert node.filters.complevel == lvl 1724s if lvl == 0: 1724s assert node.filters.complib is None 1724s else: 1724s > assert node.filters.complib == lib 1724s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1724s E 1724s E - blosc2 1724s E + blosc2:blosclz 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1724s ___________________________ test_complibs[blosc2-9] ____________________________ 1724s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-60/test_complibs_blosc2_9_0') 1724s lvl = 9, lib = 'blosc2' 1724s request = > 1724s 1724s @pytest.mark.parametrize("lvl", range(10)) 1724s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1724s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1724s @pytest.mark.skipif( 1724s not PY311 and is_ci_environment() and is_platform_linux(), 1724s reason="Segfaulting in a CI environment" 1724s # with xfail, would sometimes raise UnicodeDecodeError 1724s # invalid state byte 1724s ) 1724s def test_complibs(tmp_path, lvl, lib, request): 1724s # GH14478 1724s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1724s request.applymarker( 1724s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1724s ) 1724s df = DataFrame( 1724s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1724s ) 1724s 1724s # Remove lzo if its not available on this platform 1724s if not tables.which_lib_version("lzo"): 1724s pytest.skip("lzo not available") 1724s # Remove bzip2 if its not available on this platform 1724s if not tables.which_lib_version("bzip2"): 1724s pytest.skip("bzip2 not available") 1724s 1724s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1724s gname = f"{lvl}_{lib}" 1724s 1724s # Write and read file to see if data is consistent 1724s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1724s result = read_hdf(tmpfile, gname) 1724s tm.assert_frame_equal(result, df) 1724s 1724s # Open file and check metadata for correct amount of compression 1724s with tables.open_file(tmpfile, mode="r") as h5table: 1724s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1724s assert node.filters.complevel == lvl 1724s if lvl == 0: 1724s assert node.filters.complib is None 1724s else: 1724s > assert node.filters.complib == lib 1724s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1724s E 1724s E - blosc2 1724s E + blosc2:blosclz 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1724s ______________________ test_append_frame_column_oriented _______________________ 1724s self = 1724s node = , kwargs = {'side': 'right'} 1724s value = 1724s slobj = slice(0, 4, None) 1724s 1724s def visit_Subscript(self, node, **kwargs) -> ops.Term: 1724s # only allow simple subscripts 1724s 1724s value = self.visit(node.value) 1724s slobj = self.visit(node.slice) 1724s try: 1724s value = value.value 1724s except AttributeError: 1724s pass 1724s 1724s if isinstance(slobj, Term): 1724s # In py39 np.ndarray lookups with Term containing int raise 1724s slobj = slobj.value 1724s 1724s try: 1724s > return self.const_type(value[slobj], self.env) 1724s E TypeError: 'builtin_function_or_method' object is not subscriptable 1724s 1724s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:468: TypeError 1724s 1724s The above exception was the direct cause of the following exception: 1724s 1724s setup_path = 'tmp.__649f9220-80c7-4364-b73e-2096a0a0d7b3__.h5' 1724s 1724s @pytest.mark.xfail(condition=PY312 or is_crashing_arch, reason="https://bugs.debian.org/1055801 and https://bugs.debian.org/790925",raises=ValueError,strict=False, run=not is_crashing_arch) 1724s def test_append_frame_column_oriented(setup_path): 1724s with ensure_clean_store(setup_path) as store: 1724s # column oriented 1724s df = DataFrame( 1724s np.random.default_rng(2).standard_normal((10, 4)), 1724s columns=Index(list("ABCD"), dtype=object), 1724s index=date_range("2000-01-01", periods=10, freq="B"), 1724s ) 1724s df.index = df.index._with_freq(None) # freq doesn't round-trip 1724s 1724s _maybe_remove(store, "df1") 1724s store.append("df1", df.iloc[:, :2], axes=["columns"]) 1724s store.append("df1", df.iloc[:, 2:]) 1724s tm.assert_frame_equal(store["df1"], df) 1724s 1724s result = store.select("df1", "columns=A") 1724s expected = df.reindex(columns=["A"]) 1724s tm.assert_frame_equal(expected, result) 1724s 1724s # selection on the non-indexable 1724s > result = store.select("df1", ("columns=A", "index=df.index[0:4]")) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:311: 1724s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 1724s return it.get_result() 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 1724s results = self.func(self.start, self.stop, where) 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 1724s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 1724s result = self._read_axes(where=where, start=start, stop=stop) 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 1724s selection = Selection(self, where=where, start=start, stop=stop) 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 1724s self.terms = self.generate(where) 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 1724s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 1724s self.terms = self.parse() 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 1724s return self._visitor.visit(self.expr) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 1724s return self.visit(expr, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 1724s return self.visit(node.value, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:742: in visit_BoolOp 1724s return reduce(visitor, operands) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:736: in visitor 1724s rhs = self._try_visit_binop(y) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:731: in _try_visit_binop 1724s return self.visit(bop) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 1724s return self.visit(binop) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 1724s op, op_class, left, right = self._maybe_transform_eq_ne(node) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 1724s right = self.visit(node.right, side="right") 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1724s 1724s self = 1724s node = , kwargs = {'side': 'right'} 1724s value = 1724s slobj = slice(0, 4, None) 1724s 1724s def visit_Subscript(self, node, **kwargs) -> ops.Term: 1724s # only allow simple subscripts 1724s 1724s value = self.visit(node.value) 1724s slobj = self.visit(node.slice) 1724s try: 1724s value = value.value 1724s except AttributeError: 1724s pass 1724s 1724s if isinstance(slobj, Term): 1724s # In py39 np.ndarray lookups with Term containing int raise 1724s slobj = slobj.value 1724s 1724s try: 1724s return self.const_type(value[slobj], self.env) 1724s except TypeError as err: 1724s > raise ValueError( 1724s f"cannot subscript {repr(value)} with {repr(slobj)}" 1724s ) from err 1724s E ValueError: cannot subscript with slice(0, 4, None) 1724s 1724s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:470: ValueError 1724s __________________________ test_select_filter_corner ___________________________ 1724s setup_path = 'tmp.__02fdd8cf-2710-4b51-bc4f-c5c6f82bd7d7__.h5' 1724s 1724s @pytest.mark.xfail(condition=PY312 or is_crashing_arch, reason="https://bugs.debian.org/1055801 and https://bugs.debian.org/790925",raises=ValueError,strict=False, run=not is_crashing_arch) 1724s def test_select_filter_corner(setup_path): 1724s df = DataFrame(np.random.default_rng(2).standard_normal((50, 100))) 1724s df.index = [f"{c:3d}" for c in df.index] 1724s df.columns = [f"{c:3d}" for c in df.columns] 1724s 1724s with ensure_clean_store(setup_path) as store: 1724s store.put("frame", df, format="table") 1724s 1724s crit = "columns=df.columns[:75]" 1724s > result = store.select("frame", [crit]) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:899: 1724s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 1724s return it.get_result() 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 1724s results = self.func(self.start, self.stop, where) 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 1724s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 1724s result = self._read_axes(where=where, start=start, stop=stop) 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 1724s selection = Selection(self, where=where, start=start, stop=stop) 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 1724s self.terms = self.generate(where) 1724s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 1724s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 1724s self.terms = self.parse() 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 1724s return self._visitor.visit(self.expr) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 1724s return self.visit(expr, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 1724s return self.visit(node.value, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 1724s return self.visit(binop) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 1724s op, op_class, left, right = self._maybe_transform_eq_ne(node) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 1724s right = self.visit(node.right, side="right") 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:456: in visit_Subscript 1724s value = self.visit(node.value) 1724s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1724s return visitor(node, **kwargs) 1724s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1724s 1724s self = 1724s node = , kwargs = {}, attr = 'columns' 1724s value = , ctx = 1724s resolved = 'df' 1724s 1724s def visit_Attribute(self, node, **kwargs): 1724s attr = node.attr 1724s value = node.value 1724s 1724s ctx = type(node.ctx) 1724s if ctx == ast.Load: 1724s # resolve the value 1724s resolved = self.visit(value) 1724s 1724s # try to get the value to see if we are another expression 1724s try: 1724s resolved = resolved.value 1724s except AttributeError: 1724s pass 1724s 1724s try: 1724s return self.term_type(getattr(resolved, attr), self.env) 1724s except AttributeError: 1724s # something like datetime.datetime where scope is overridden 1724s if isinstance(value, ast.Name) and value.id == attr: 1724s return resolved 1724s 1724s > raise ValueError(f"Invalid Attribute context {ctx.__name__}") 1724s E ValueError: Invalid Attribute context Load 1724s 1724s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:496: ValueError 1724s __________________ test_frame_setitem_dask_array_into_new_col __________________ 1724s @pytest.mark.xfail( 1724s condition=True,#not IS64, 1724s reason="ignoring https://bugs.debian.org/1094417 to unblock transition",#"dask has different nativesize-int vs int64 type rules", 1724s strict=False, 1724s ) 1724s def test_frame_setitem_dask_array_into_new_col(): 1724s # GH#47128 1724s 1724s # dask sets "compute.use_numexpr" to False, so catch the current value 1724s # and ensure to reset it afterwards to avoid impacting other tests 1724s olduse = pd.get_option("compute.use_numexpr") 1724s 1724s try: 1724s da = td.versioned_importorskip("dask.array") 1724s 1724s dda = da.array([1, 2]) 1724s df = DataFrame({"a": ["a", "b"]}) 1724s df["b"] = dda 1724s df["c"] = dda 1724s df.loc[[False, True], "b"] = 100 1724s result = df.loc[[1], :] 1724s expected = DataFrame({"a": ["b"], "b": [100], "c": [2]}, index=[1]) 1724s > tm.assert_frame_equal(result, expected) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:256: 1724s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1724s 1724s left = array([100]), right = array([2]), err_msg = None 1724s 1724s def _raise(left, right, err_msg) -> NoReturn: 1724s if err_msg is None: 1724s if left.shape != right.shape: 1724s raise_assert_detail( 1724s obj, f"{obj} shapes are different", left.shape, right.shape 1724s ) 1724s 1724s diff = 0 1724s for left_arr, right_arr in zip(left, right): 1724s # count up differences 1724s if not array_equivalent(left_arr, right_arr, strict_nan=strict_nan): 1724s diff += 1 1724s 1724s diff = diff * 100.0 / left.size 1724s msg = f"{obj} values are different ({np.round(diff, 5)} %)" 1724s > raise_assert_detail(obj, msg, left, right, index_values=index_values) 1724s E AssertionError: DataFrame.iloc[:, 2] (column name="c") are different 1724s E 1724s E DataFrame.iloc[:, 2] (column name="c") values are different (100.0 %) 1724s E [index]: [1] 1724s E [left]: [100] 1724s E [right]: [2] 1724s 1724s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:684: AssertionError 1724s ________ TestDataFrameToXArray.test_to_xarray_index_types[datetime-tz] _________ 1724s self = 1724s index_flat = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1724s '2020-01-03 00:00:00-08:00', '... '2020-04-08 00:00:00-07:00', '2020-04-09 00:00:00-07:00'], 1724s dtype='datetime64[ns, US/Pacific]', freq='D') 1724s df = bar a b c ... f g h 1724s foo .....03 00:00:00-05:00 1724s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 1724s 1724s [4 rows x 8 columns] 1724s using_infer_string = False 1724s 1724s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1724s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1724s index = index_flat 1724s # MultiIndex is tested in test_to_xarray_with_multiindex 1724s if len(index) == 0: 1724s pytest.skip("Test doesn't make sense for empty index") 1724s 1724s from xarray import Dataset 1724s 1724s df.index = index[:4] 1724s df.index.name = "foo" 1724s df.columns.name = "bar" 1724s result = df.to_xarray() 1724s assert result.sizes["foo"] == 4 1724s assert len(result.coords) == 1 1724s assert len(result.data_vars) == 8 1724s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1724s assert isinstance(result, Dataset) 1724s 1724s # idempotency 1724s # datetimes w/tz are preserved 1724s # column names are lost 1724s expected = df.copy() 1724s # breaks in xarray >= 2024.10.0(?) 1724s # debug print 1724s r0 = result.to_dataframe() 1724s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1724s expected.columns.name = None 1724s > tm.assert_frame_equal(result.to_dataframe(), expected) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1724s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1724s 1724s left = Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 1724s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 1724s dtype='object', name='foo') 1724s right = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1724s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 1724s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 1724s obj = 'DataFrame.index' 1724s 1724s def _check_types(left, right, obj: str = "Index") -> None: 1724s if not exact: 1724s return 1724s 1724s > assert_class_equal(left, right, exact=exact, obj=obj) 1724s E AssertionError: DataFrame.index are different 1724s E 1724s E DataFrame.index classes are different 1724s E [left]: Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 1724s E 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 1724s E dtype='object', name='foo') 1724s E [right]: DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1724s E '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 1724s E dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 1724s 1724s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 1724s ________ TestDataFrameToXArray.test_to_xarray_index_types[bool-object] _________ 1724s self = 1724s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='object') 1724s df = bar a b c d e f g h 1724s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1724s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1724s using_infer_string = False 1724s 1724s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1724s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1724s index = index_flat 1724s # MultiIndex is tested in test_to_xarray_with_multiindex 1724s if len(index) == 0: 1724s pytest.skip("Test doesn't make sense for empty index") 1724s 1724s from xarray import Dataset 1724s 1724s df.index = index[:4] 1724s df.index.name = "foo" 1724s df.columns.name = "bar" 1724s result = df.to_xarray() 1724s assert result.sizes["foo"] == 4 1724s assert len(result.coords) == 1 1724s assert len(result.data_vars) == 8 1724s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1724s assert isinstance(result, Dataset) 1724s 1724s # idempotency 1724s # datetimes w/tz are preserved 1724s # column names are lost 1724s expected = df.copy() 1724s # breaks in xarray >= 2024.10.0(?) 1724s # debug print 1724s r0 = result.to_dataframe() 1724s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1724s expected.columns.name = None 1724s > tm.assert_frame_equal(result.to_dataframe(), expected) 1724s E AssertionError: DataFrame are different 1724s E 1724s E DataFrame shape mismatch 1724s E [left]: (8, 8) 1724s E [right]: (4, 8) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1724s _________ TestDataFrameToXArray.test_to_xarray_index_types[bool-dtype] _________ 1724s self = 1724s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='bool') 1724s df = bar a b c d e f g h 1724s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1724s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1724s using_infer_string = False 1724s 1724s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1724s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1724s index = index_flat 1724s # MultiIndex is tested in test_to_xarray_with_multiindex 1724s if len(index) == 0: 1724s pytest.skip("Test doesn't make sense for empty index") 1724s 1724s from xarray import Dataset 1724s 1724s df.index = index[:4] 1724s df.index.name = "foo" 1724s df.columns.name = "bar" 1724s result = df.to_xarray() 1724s assert result.sizes["foo"] == 4 1724s assert len(result.coords) == 1 1724s assert len(result.data_vars) == 8 1724s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1724s assert isinstance(result, Dataset) 1724s 1724s # idempotency 1724s # datetimes w/tz are preserved 1724s # column names are lost 1724s expected = df.copy() 1724s # breaks in xarray >= 2024.10.0(?) 1724s # debug print 1724s r0 = result.to_dataframe() 1724s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1724s expected.columns.name = None 1724s > tm.assert_frame_equal(result.to_dataframe(), expected) 1724s E AssertionError: DataFrame are different 1724s E 1724s E DataFrame shape mismatch 1724s E [left]: (8, 8) 1724s E [right]: (4, 8) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1724s ________ TestDataFrameToXArray.test_to_xarray_index_types[categorical] _________ 1724s self = 1724s index_flat = CategoricalIndex(['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 1724s 'a', 'b', 'c', 'd', 'a... 'a', 'b', 'c', 'd'], 1724s categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category') 1724s df = bar a b c d e f g h 1724s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1724s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1724s using_infer_string = False 1724s 1724s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1724s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1724s index = index_flat 1724s # MultiIndex is tested in test_to_xarray_with_multiindex 1724s if len(index) == 0: 1724s pytest.skip("Test doesn't make sense for empty index") 1724s 1724s from xarray import Dataset 1724s 1724s df.index = index[:4] 1724s df.index.name = "foo" 1724s df.columns.name = "bar" 1724s result = df.to_xarray() 1724s assert result.sizes["foo"] == 4 1724s assert len(result.coords) == 1 1724s assert len(result.data_vars) == 8 1724s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1724s assert isinstance(result, Dataset) 1724s 1724s # idempotency 1724s # datetimes w/tz are preserved 1724s # column names are lost 1724s expected = df.copy() 1724s # breaks in xarray >= 2024.10.0(?) 1724s # debug print 1724s r0 = result.to_dataframe() 1724s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1724s expected.columns.name = None 1724s > tm.assert_frame_equal(result.to_dataframe(), expected) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1724s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1724s 1724s left = Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 1724s right = CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 1724s obj = 'DataFrame.index' 1724s 1724s def _check_types(left, right, obj: str = "Index") -> None: 1724s if not exact: 1724s return 1724s 1724s > assert_class_equal(left, right, exact=exact, obj=obj) 1724s E AssertionError: DataFrame.index are different 1724s E 1724s E DataFrame.index classes are different 1724s E [left]: Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 1724s E [right]: CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 1724s 1724s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 1724s __________ TestDataFrameToXArray.test_to_xarray_index_types[repeats] ___________ 1724s self = 1724s index_flat = Index([0, 0, 1, 1, 2, 2], dtype='int64') 1724s df = bar a b c d e f g h 1724s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1724s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1724s using_infer_string = False 1724s 1724s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1724s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1724s index = index_flat 1724s # MultiIndex is tested in test_to_xarray_with_multiindex 1724s if len(index) == 0: 1724s pytest.skip("Test doesn't make sense for empty index") 1724s 1724s from xarray import Dataset 1724s 1724s df.index = index[:4] 1724s df.index.name = "foo" 1724s df.columns.name = "bar" 1724s result = df.to_xarray() 1724s assert result.sizes["foo"] == 4 1724s assert len(result.coords) == 1 1724s assert len(result.data_vars) == 8 1724s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1724s assert isinstance(result, Dataset) 1724s 1724s # idempotency 1724s # datetimes w/tz are preserved 1724s # column names are lost 1724s expected = df.copy() 1724s # breaks in xarray >= 2024.10.0(?) 1724s # debug print 1724s r0 = result.to_dataframe() 1724s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1724s expected.columns.name = None 1724s > tm.assert_frame_equal(result.to_dataframe(), expected) 1724s E AssertionError: DataFrame are different 1724s E 1724s E DataFrame shape mismatch 1724s E [left]: (8, 8) 1724s E [right]: (4, 8) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1724s ________ TestDataFrameToXArray.test_to_xarray_index_types[nullable_int] ________ 1724s self = 1724s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1724s 18, 19, 20, 21, 22, 23, 24, 25, ...7, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 1724s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 1724s dtype='Int64') 1724s df = bar a b c d e f g h 1724s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1724s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1724s using_infer_string = False 1724s 1724s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1724s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1724s index = index_flat 1724s # MultiIndex is tested in test_to_xarray_with_multiindex 1724s if len(index) == 0: 1724s pytest.skip("Test doesn't make sense for empty index") 1724s 1724s from xarray import Dataset 1724s 1724s df.index = index[:4] 1724s df.index.name = "foo" 1724s df.columns.name = "bar" 1724s result = df.to_xarray() 1724s assert result.sizes["foo"] == 4 1724s assert len(result.coords) == 1 1724s assert len(result.data_vars) == 8 1724s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1724s assert isinstance(result, Dataset) 1724s 1724s # idempotency 1724s # datetimes w/tz are preserved 1724s # column names are lost 1724s expected = df.copy() 1724s # breaks in xarray >= 2024.10.0(?) 1724s # debug print 1724s r0 = result.to_dataframe() 1724s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1724s expected.columns.name = None 1724s > tm.assert_frame_equal(result.to_dataframe(), expected) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1724s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1724s 1724s left = Index([0, 1, 2, 3], dtype='object', name='foo') 1724s right = Index([0, 1, 2, 3], dtype='Int64', name='foo'), obj = 'DataFrame.index' 1724s 1724s def _check_types(left, right, obj: str = "Index") -> None: 1724s if not exact: 1724s return 1724s 1724s assert_class_equal(left, right, exact=exact, obj=obj) 1724s assert_attr_equal("inferred_type", left, right, obj=obj) 1724s 1724s # Skip exact dtype checking when `check_categorical` is False 1724s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1724s right.dtype, CategoricalDtype 1724s ): 1724s if check_categorical: 1724s assert_attr_equal("dtype", left, right, obj=obj) 1724s assert_index_equal(left.categories, right.categories, exact=exact) 1724s return 1724s 1724s > assert_attr_equal("dtype", left, right, obj=obj) 1724s E AssertionError: DataFrame.index are different 1724s E 1724s E Attribute "dtype" are different 1724s E [left]: object 1724s E [right]: Int64 1724s 1724s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1724s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_uint] ________ 1724s self = 1724s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1724s 18, 19, 20, 21, 22, 23, 24, 25, ..., 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 1724s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 1724s dtype='UInt16') 1724s df = bar a b c d e f g h 1724s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1724s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1724s using_infer_string = False 1724s 1724s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1724s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1724s index = index_flat 1724s # MultiIndex is tested in test_to_xarray_with_multiindex 1724s if len(index) == 0: 1724s pytest.skip("Test doesn't make sense for empty index") 1724s 1724s from xarray import Dataset 1724s 1724s df.index = index[:4] 1724s df.index.name = "foo" 1724s df.columns.name = "bar" 1724s result = df.to_xarray() 1724s assert result.sizes["foo"] == 4 1724s assert len(result.coords) == 1 1724s assert len(result.data_vars) == 8 1724s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1724s assert isinstance(result, Dataset) 1724s 1724s # idempotency 1724s # datetimes w/tz are preserved 1724s # column names are lost 1724s expected = df.copy() 1724s # breaks in xarray >= 2024.10.0(?) 1724s # debug print 1724s r0 = result.to_dataframe() 1724s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1724s expected.columns.name = None 1724s > tm.assert_frame_equal(result.to_dataframe(), expected) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1724s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1724s 1724s left = Index([0, 1, 2, 3], dtype='object', name='foo') 1724s right = Index([0, 1, 2, 3], dtype='UInt16', name='foo'), obj = 'DataFrame.index' 1724s 1724s def _check_types(left, right, obj: str = "Index") -> None: 1724s if not exact: 1724s return 1724s 1724s assert_class_equal(left, right, exact=exact, obj=obj) 1724s assert_attr_equal("inferred_type", left, right, obj=obj) 1724s 1724s # Skip exact dtype checking when `check_categorical` is False 1724s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1724s right.dtype, CategoricalDtype 1724s ): 1724s if check_categorical: 1724s assert_attr_equal("dtype", left, right, obj=obj) 1724s assert_index_equal(left.categories, right.categories, exact=exact) 1724s return 1724s 1724s > assert_attr_equal("dtype", left, right, obj=obj) 1724s E AssertionError: DataFrame.index are different 1724s E 1724s E Attribute "dtype" are different 1724s E [left]: object 1724s E [right]: UInt16 1724s 1724s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1724s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_float] _______ 1724s self = 1724s index_flat = Index([ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 1724s 12.0, 13.0, 14.0, 15.0, 16.0, 17...5.0, 86.0, 87.0, 88.0, 89.0, 90.0, 91.0, 92.0, 93.0, 94.0, 95.0, 1724s 96.0, 97.0, 98.0, 99.0], 1724s dtype='Float32') 1724s df = bar a b c d e f g h 1724s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1724s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1724s using_infer_string = False 1724s 1724s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1724s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1724s index = index_flat 1724s # MultiIndex is tested in test_to_xarray_with_multiindex 1724s if len(index) == 0: 1724s pytest.skip("Test doesn't make sense for empty index") 1724s 1724s from xarray import Dataset 1724s 1724s df.index = index[:4] 1724s df.index.name = "foo" 1724s df.columns.name = "bar" 1724s result = df.to_xarray() 1724s assert result.sizes["foo"] == 4 1724s assert len(result.coords) == 1 1724s assert len(result.data_vars) == 8 1724s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1724s assert isinstance(result, Dataset) 1724s 1724s # idempotency 1724s # datetimes w/tz are preserved 1724s # column names are lost 1724s expected = df.copy() 1724s # breaks in xarray >= 2024.10.0(?) 1724s # debug print 1724s r0 = result.to_dataframe() 1724s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1724s expected.columns.name = None 1724s > tm.assert_frame_equal(result.to_dataframe(), expected) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1724s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1724s 1724s left = Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 1724s right = Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 1724s obj = 'DataFrame.index' 1724s 1724s def _check_types(left, right, obj: str = "Index") -> None: 1724s if not exact: 1724s return 1724s 1724s assert_class_equal(left, right, exact=exact, obj=obj) 1724s assert_attr_equal("inferred_type", left, right, obj=obj) 1724s 1724s # Skip exact dtype checking when `check_categorical` is False 1724s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1724s right.dtype, CategoricalDtype 1724s ): 1724s if check_categorical: 1724s assert_attr_equal("dtype", left, right, obj=obj) 1724s assert_index_equal(left.categories, right.categories, exact=exact) 1724s return 1724s 1724s > assert_attr_equal("dtype", left, right, obj=obj) 1724s E AssertionError: DataFrame.index are different 1724s E 1724s E Attribute "dtype" are different 1724s E [left]: object 1724s E [right]: Float32 1724s 1724s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1724s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_bool] ________ 1724s self = 1724s index_flat = Index([False, True, True, True, True, True, True, True, True, True, 1724s True, True, True, True, True,...rue, True, True, 1724s True, True, True, True, True, True, True, True, True, True], 1724s dtype='boolean') 1724s df = bar a b c d e f g h 1724s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1724s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1724s using_infer_string = False 1724s 1724s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1724s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1724s index = index_flat 1724s # MultiIndex is tested in test_to_xarray_with_multiindex 1724s if len(index) == 0: 1724s pytest.skip("Test doesn't make sense for empty index") 1724s 1724s from xarray import Dataset 1724s 1724s df.index = index[:4] 1724s df.index.name = "foo" 1724s df.columns.name = "bar" 1724s result = df.to_xarray() 1724s assert result.sizes["foo"] == 4 1724s assert len(result.coords) == 1 1724s assert len(result.data_vars) == 8 1724s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1724s assert isinstance(result, Dataset) 1724s 1724s # idempotency 1724s # datetimes w/tz are preserved 1724s # column names are lost 1724s expected = df.copy() 1724s # breaks in xarray >= 2024.10.0(?) 1724s # debug print 1724s r0 = result.to_dataframe() 1724s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1724s expected.columns.name = None 1724s > tm.assert_frame_equal(result.to_dataframe(), expected) 1724s E AssertionError: DataFrame are different 1724s E 1724s E DataFrame shape mismatch 1724s E [left]: (10, 8) 1724s E [right]: (4, 8) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1724s _______ TestDataFrameToXArray.test_to_xarray_index_types[string-python] ________ 1724s self = 1724s index_flat = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3', 'pandas_4', 'pandas_5', 1724s 'pandas_6', 'pandas_7', 'pandas_...pandas_93', 'pandas_94', 'pandas_95', 1724s 'pandas_96', 'pandas_97', 'pandas_98', 'pandas_99'], 1724s dtype='string') 1724s df = bar a b c d e f g h 1724s foo ....0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1724s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1724s using_infer_string = False 1724s 1724s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1724s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1724s index = index_flat 1724s # MultiIndex is tested in test_to_xarray_with_multiindex 1724s if len(index) == 0: 1724s pytest.skip("Test doesn't make sense for empty index") 1724s 1724s from xarray import Dataset 1724s 1724s df.index = index[:4] 1724s df.index.name = "foo" 1724s df.columns.name = "bar" 1724s result = df.to_xarray() 1724s assert result.sizes["foo"] == 4 1724s assert len(result.coords) == 1 1724s assert len(result.data_vars) == 8 1724s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1724s assert isinstance(result, Dataset) 1724s 1724s # idempotency 1724s # datetimes w/tz are preserved 1724s # column names are lost 1724s expected = df.copy() 1724s # breaks in xarray >= 2024.10.0(?) 1724s # debug print 1724s r0 = result.to_dataframe() 1724s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1724s expected.columns.name = None 1724s > tm.assert_frame_equal(result.to_dataframe(), expected) 1724s 1724s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1724s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1724s 1724s left = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 1724s right = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 1724s obj = 'DataFrame.index' 1724s 1724s def _check_types(left, right, obj: str = "Index") -> None: 1724s if not exact: 1724s return 1724s 1724s assert_class_equal(left, right, exact=exact, obj=obj) 1724s assert_attr_equal("inferred_type", left, right, obj=obj) 1724s 1724s # Skip exact dtype checking when `check_categorical` is False 1724s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1724s right.dtype, CategoricalDtype 1724s ): 1724s if check_categorical: 1724s assert_attr_equal("dtype", left, right, obj=obj) 1724s assert_index_equal(left.categories, right.categories, exact=exact) 1724s return 1724s 1724s > assert_attr_equal("dtype", left, right, obj=obj) 1724s E AssertionError: DataFrame.index are different 1724s E 1724s E Attribute "dtype" are different 1724s E [left]: object 1724s E [right]: string[python] 1724s 1724s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1724s =============================== warnings summary =============================== 1724s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:39 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:39: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1724s pytestmark = pytest.mark.single_cpu 1724s 1724s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:30 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:30: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1724s pytestmark = pytest.mark.single_cpu 1724s 1724s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:39 1724s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:39: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1724s pytestmark = pytest.mark.single_cpu 1724s 1724s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:119 1724s /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:119: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1724s @pytest.mark.single_cpu 1724s 1724s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:125 1724s /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:125: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1724s @pytest.mark.single_cpu 1724s 1724s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:196 1724s /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:196: PytestUnknownMarkWarning: Unknown pytest.mark.single_cpu - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 1724s @pytest.mark.single_cpu 1724s 1724s io/pytables/test_file_handling.py: 191 warnings 1724s io/pytables/test_append.py: 21 warnings 1724s io/pytables/test_store.py: 66 warnings 1724s test_downstream.py: 26 warnings 1724s generic/test_to_xarray.py: 62 warnings 1724s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=17322) is multi-threaded, use of fork() may lead to deadlocks in the child. 1724s pid = os.fork() 1724s 1724s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1724s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-65bsvznw' 1724s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1724s 1724s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 1724s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/lastfailed: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-hkk9fh1a' 1724s config.cache.set("cache/lastfailed", self.lastfailed) 1724s 1724s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1724s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-2bb7ujme' 1724s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1724s 1724s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1724s =========================== short test summary info ============================ 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-1] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-2] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-3] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-4] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-5] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-6] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-7] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-8] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-9] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py::test_append_frame_column_oriented 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py::test_select_filter_corner 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py::test_frame_setitem_dask_array_into_new_col 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 1724s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 1724s =========== 22 failed, 335 passed, 9 skipped, 375 warnings in 26.40s =========== 1724s pymysql/psycopg2 tests, which do not work in this test environment 1725s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1725s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1725s 1725s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1726s ============================= test session starts ============================== 1726s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1726s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1726s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1726s plugins: xdist-3.6.1, forked-1.6.0, hypothesis-6.127.4, qt-4.4.0, localserver-0.9.0.post0, typeguard-4.4.2, asyncio-0.25.1 1726s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1726s collected 2513 items 1726s 2544s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py FEFEFEFE....ssFEFEFEFE....ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE...FEFEFEFE....ssFEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...xssFEFEFEFEFEFEFEFExxxxFEFExxxxssFEFEFEFE...FEFEFEFE....ssFEFEFEFE....ssxxxxxxxx....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE...xssFEFEFEFE...xssFEFEFEFE...xssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE...xssFEFEFEFE...xssFEFEFEFE...xssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssxxxxFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE...xssFEFEFEFE...xssFEFEFEFE...xss.FEFEFEFE...xssFEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE....EFE.EFE....ss.EFE.EFE....ssFEFEFEFE...FEFEFEFE...FEFEFEFE...xss.ss...FEFEFEFE..sFEFEFEFE..sFEFEFEFE..s.ssFEFEFEFE....ssFEFEFEFE...FEFEFEFE...FEFEFEFE...xxxxFEFExxxFEFEFEFE...FEFEFEFExxxFEFEFEFEFEFEFEFEFEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE..xFEFEFEFE..sFEFEFEFE..sFEFEFEFE..sFEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE...FEFEFEFE..sFEFEFEFE...xssFEFEFEFE....ssFEFEFEFE...FEFEFEFE....ss..FEFEFEFE....ssFEFEFEFE....ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssFEFEFEFExxxxssFEFEFEFExxxxssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ssFEFEFEFE....ss....s..FEFE................ 2562s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss......................................................................................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 2562s 2562s ==================================== ERRORS ==================================== 2562s _______ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_engine] _______ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s ________ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_conn] ________ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s ____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_engine] ____ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_conn] _____ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s ____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_engine] ____ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_conn] _____ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_engine] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s __ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_conn] __ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _________ ERROR at teardown of test_to_sql[None-mysql_pymysql_engine] __________ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s __________ ERROR at teardown of test_to_sql[None-mysql_pymysql_conn] ___________ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s ______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_engine] _______ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_conn] ________ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_engine] _________ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s __________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_conn] __________ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s ______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_engine] ______ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_conn] _______ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s ____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_engine] ____ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_conn] _____ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_engine] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s __ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_conn] __ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s ____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_engine] _____ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_conn] ______ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_engine] __ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s __ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_conn] ___ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s ______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_engine] _______ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_conn] ________ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s ___ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_engine] ____ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s ____ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_conn] _____ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _____ ERROR at teardown of test_read_iris_query[mysql_pymysql_engine_iris] _____ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s ______ ERROR at teardown of test_read_iris_query[mysql_pymysql_conn_iris] ______ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s __ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_engine_iris] __ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s ___ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_conn_iris] ___ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_engine_iris] _ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_conn_iris] _ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] _ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] _ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] _ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _____ ERROR at teardown of test_read_iris_table[mysql_pymysql_engine_iris] _____ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s ______ ERROR at teardown of test_read_iris_table[mysql_pymysql_conn_iris] ______ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s __ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_engine_iris] __ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s ___ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_conn_iris] ___ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_engine_iris] _ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_conn_iris] _ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _______ ERROR at teardown of test_to_sql_callable[mysql_pymysql_engine] ________ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s ________ ERROR at teardown of test_to_sql_callable[mysql_pymysql_conn] _________ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s ____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_engine] _____ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_conn] ______ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_engine_types] _ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_conn_types] __ 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s > sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3.13/socket.py:864: in create_connection 2562s raise exceptions[0] 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s address = ('localhost', 3306), timeout = 10, source_address = None 2562s 2562s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2562s source_address=None, *, all_errors=False): 2562s """Connect to *address* and return the socket object. 2562s 2562s Convenience function. Connect to *address* (a 2-tuple ``(host, 2562s port)``) and return the socket object. Passing the optional 2562s *timeout* parameter will set the timeout on the socket instance 2562s before attempting to connect. If no *timeout* is supplied, the 2562s global default timeout setting returned by :func:`getdefaulttimeout` 2562s is used. If *source_address* is set it must be a tuple of (host, port) 2562s for the socket to bind as a source address before making the connection. 2562s A host of '' or port 0 tells the OS to use the default. When a connection 2562s cannot be created, raises the last error if *all_errors* is False, 2562s and an ExceptionGroup of all errors if *all_errors* is True. 2562s """ 2562s 2562s host, port = address 2562s exceptions = [] 2562s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2562s af, socktype, proto, canonname, sa = res 2562s sock = None 2562s try: 2562s sock = socket(af, socktype, proto) 2562s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2562s sock.settimeout(timeout) 2562s if source_address: 2562s sock.bind(source_address) 2562s > sock.connect(sa) 2562s E ConnectionRefusedError: [Errno 111] Connection refused 2562s 2562s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2562s 2562s During handling of the above exception, another exception occurred: 2562s 2562s self = 2562s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2562s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def mysql_pymysql_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s pymysql = td.versioned_importorskip("pymysql") 2562s engine = sqlalchemy.create_engine( 2562s "mysql+pymysql://root@localhost:3306/pandas", 2562s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2562s self.connect() 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s self = , sock = None 2562s 2562s def connect(self, sock=None): 2562s self._closed = False 2562s try: 2562s if sock is None: 2562s if self.unix_socket: 2562s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2562s sock.settimeout(self.connect_timeout) 2562s sock.connect(self.unix_socket) 2562s self.host_info = "Localhost via UNIX socket" 2562s self._secure = True 2562s if DEBUG: 2562s print("connected using unix_socket") 2562s else: 2562s kwargs = {} 2562s if self.bind_address is not None: 2562s kwargs["source_address"] = (self.bind_address, 0) 2562s while True: 2562s try: 2562s sock = socket.create_connection( 2562s (self.host, self.port), self.connect_timeout, **kwargs 2562s ) 2562s break 2562s except OSError as e: 2562s if e.errno == errno.EINTR: 2562s continue 2562s raise 2562s self.host_info = "socket %s:%d" % (self.host, self.port) 2562s if DEBUG: 2562s print("connected using socket") 2562s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2562s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2562s sock.settimeout(None) 2562s 2562s self._sock = sock 2562s self._rfile = sock.makefile("rb") 2562s self._next_seq_id = 0 2562s 2562s self._get_server_information() 2562s self._request_authentication() 2562s 2562s # Send "SET NAMES" query on init for: 2562s # - Ensure charaset (and collation) is set to the server. 2562s # - collation_id in handshake packet may be ignored. 2562s # - If collation is not specified, we don't know what is server's 2562s # default collation for the charset. For example, default collation 2562s # of utf8mb4 is: 2562s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2562s # - MySQL 8.0: utf8mb4_0900_ai_ci 2562s # 2562s # Reference: 2562s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2562s # - https://github.com/wagtail/wagtail/issues/9477 2562s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2562s self.set_character_set(self.charset, self.collation) 2562s 2562s if self.sql_mode is not None: 2562s c = self.cursor() 2562s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2562s c.close() 2562s 2562s if self.init_command is not None: 2562s c = self.cursor() 2562s c.execute(self.init_command) 2562s c.close() 2562s 2562s if self.autocommit_mode is not None: 2562s self.autocommit(self.autocommit_mode) 2562s except BaseException as e: 2562s self._rfile = None 2562s if sock is not None: 2562s try: 2562s sock.close() 2562s except: # noqa 2562s pass 2562s 2562s if isinstance(e, (OSError, IOError)): 2562s exc = err.OperationalError( 2562s CR.CR_CONN_HOST_ERROR, 2562s f"Can't connect to MySQL server on {self.host!r} ({e})", 2562s ) 2562s # Keep original exception and traceback to investigate error. 2562s exc.original_exception = e 2562s exc.traceback = traceback.format_exc() 2562s if DEBUG: 2562s print(exc.traceback) 2562s > raise exc 2562s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2562s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_engine_types] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2562s return inspect(conn).get_view_names() 2562s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2562s ret = reg(subject) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2562s return Inspector._construct(Inspector._init_engine, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2562s init(self, bind) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2562s engine.connect().close() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2562s return self._connection_cls(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2562s Connection._handle_dbapi_exception_noconnection( 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2562s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2562s self._dbapi_connection = engine.raw_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E 2562s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_conn_types] _ 2562s self = 2562s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2562s connection = None, _has_events = None, _allow_revalidate = True 2562s _allow_autobegin = True 2562s 2562s def __init__( 2562s self, 2562s engine: Engine, 2562s connection: Optional[PoolProxiedConnection] = None, 2562s _has_events: Optional[bool] = None, 2562s _allow_revalidate: bool = True, 2562s _allow_autobegin: bool = True, 2562s ): 2562s """Construct a new Connection.""" 2562s self.engine = engine 2562s self.dialect = dialect = engine.dialect 2562s 2562s if connection is None: 2562s try: 2562s > self._dbapi_connection = engine.raw_connection() 2562s 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2562s return self.pool.connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2562s return _ConnectionFairy._checkout(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2562s fairy = _ConnectionRecord.checkout(pool) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2562s rec = pool._do_get() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2562s return self._create_connection() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2562s return _ConnectionRecord(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2562s self.__connect() 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2562s with util.safe_reraise(): 2562s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2562s raise exc_value.with_traceback(exc_tb) 2562s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2562s self.dbapi_connection = connection = pool._invoke_creator(self) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2562s return dialect.connect(*cargs, **cparams) 2562s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2562s return self.loaded_dbapi.connect(*cargs, **cparams) 2562s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2562s 2562s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2562s connection_factory = None, cursor_factory = None 2562s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2562s kwasync = {} 2562s 2562s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2562s """ 2562s Create a new database connection. 2562s 2562s The connection parameters can be specified as a string: 2562s 2562s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2562s 2562s or using a set of keyword arguments: 2562s 2562s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2562s 2562s Or as a mix of both. The basic connection parameters are: 2562s 2562s - *dbname*: the database name 2562s - *database*: the database name (only as keyword argument) 2562s - *user*: user name used to authenticate 2562s - *password*: password used to authenticate 2562s - *host*: database host address (defaults to UNIX socket if not provided) 2562s - *port*: connection port number (defaults to 5432 if not provided) 2562s 2562s Using the *connection_factory* parameter a different class or connections 2562s factory can be specified. It should be a callable object taking a dsn 2562s argument. 2562s 2562s Using the *cursor_factory* parameter, a new default cursor factory will be 2562s used by cursor(). 2562s 2562s Using *async*=True an asynchronous connection will be created. *async_* is 2562s a valid alias (for Python versions where ``async`` is a keyword). 2562s 2562s Any other keyword parameter will be passed to the underlying client 2562s library: the list of supported parameters depends on the library version. 2562s 2562s """ 2562s kwasync = {} 2562s if 'async' in kwargs: 2562s kwasync['async'] = kwargs.pop('async') 2562s if 'async_' in kwargs: 2562s kwasync['async_'] = kwargs.pop('async_') 2562s 2562s dsn = _ext.make_dsn(dsn, **kwargs) 2562s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2562s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2562s E Is the server running on that host and accepting TCP/IP connections? 2562s 2562s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2562s 2562s The above exception was the direct cause of the following exception: 2562s 2562s @pytest.fixture 2562s def postgresql_psycopg2_engine(): 2562s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2562s td.versioned_importorskip("psycopg2") 2562s engine = sqlalchemy.create_engine( 2562s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2562s poolclass=sqlalchemy.pool.NullPool, 2562s ) 2562s yield engine 2562s > for view in get_all_views(engine): 2562s 2562s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ________ ERROR at teardown of test_read_procedure[mysql_pymysql_engine] ________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _________ ERROR at teardown of test_read_procedure[mysql_pymysql_conn] _________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_conn] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_engine] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_conn] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_engine_iris] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s __ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_conn_iris] __ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_engine_iris] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_conn_iris] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_engine_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_conn_iris] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __________ ERROR at teardown of test_api_to_sql[mysql_pymysql_engine] __________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___________ ERROR at teardown of test_api_to_sql[mysql_pymysql_conn] ___________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_engine] _______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ________ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_conn] ________ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _______ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_engine] ________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ________ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_conn] _________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_engine] _____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_conn] ______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_engine] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_conn] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_engine] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_conn] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_engine] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_conn] ________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_engine] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_conn] _____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_engine] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_conn] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_conn] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_engine] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_conn] ________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_engine] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_conn] _____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_engine] _________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_conn] __________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_engine] ______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_conn] _______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_engine] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_conn] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_conn] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _____ ERROR at teardown of test_api_execute_sql[mysql_pymysql_engine_iris] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ______ ERROR at teardown of test_api_execute_sql[mysql_pymysql_conn_iris] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s __ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_engine_iris] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_conn_iris] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_engine_types] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_conn_types] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_conn_types] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_api_date_and_index[mysql_pymysql_engine_types] ___ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_api_date_and_index[mysql_pymysql_conn_types] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ________ ERROR at teardown of test_api_timedelta[mysql_pymysql_engine] _________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _________ ERROR at teardown of test_api_timedelta[mysql_pymysql_conn] __________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_engine] ______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_conn] _______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_engine] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_conn] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_engine] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_conn] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_engine] ___ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_conn] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_engine] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_conn] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_conn] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_engine] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_conn] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_conn] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_engine] ___ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_conn] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_engine] ___ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_conn] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_engine] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_conn] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_engine] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_conn] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ________ ERROR at teardown of test_api_get_schema[mysql_pymysql_engine] ________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _________ ERROR at teardown of test_api_get_schema[mysql_pymysql_conn] _________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_engine] _____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_conn] ______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_engine] __ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_conn] ___ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_engine] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_conn] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_engine] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_conn] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _____ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_engine] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ______ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_conn] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s __ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_engine] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_conn] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_engine] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_conn] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_engine] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_conn] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _______ ERROR at teardown of test_api_categorical[mysql_pymysql_engine] ________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ________ ERROR at teardown of test_api_categorical[mysql_pymysql_conn] _________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_engine] _____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_conn] ______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_engine] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_conn] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_conn] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_engine] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_conn] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_conn] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_read_table_columns[mysql_pymysql_engine] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_read_table_columns[mysql_pymysql_conn] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_engine] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_conn] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _____ ERROR at teardown of test_read_table_index_col[mysql_pymysql_engine] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ______ ERROR at teardown of test_read_table_index_col[mysql_pymysql_conn] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s __ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_engine] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_conn] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_engine_iris] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_conn_iris] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_engine_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_conn_iris] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_engine] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_conn] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _____ ERROR at teardown of test_database_uri_string[mysql_pymysql_engine] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ______ ERROR at teardown of test_database_uri_string[mysql_pymysql_conn] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s __ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_engine] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_conn] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_engine_iris] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_conn_iris] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_engine_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_conn_iris] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_engine_iris] ___ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_conn_iris] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_engine_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_conn_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_engine] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_conn] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_conn] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _________ ERROR at teardown of test_create_table[mysql_pymysql_engine] _________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s __________ ERROR at teardown of test_create_table[mysql_pymysql_conn] __________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ______ ERROR at teardown of test_create_table[postgresql_psycopg2_engine] ______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _______ ERROR at teardown of test_create_table[postgresql_psycopg2_conn] _______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __________ ERROR at teardown of test_drop_table[mysql_pymysql_engine] __________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___________ ERROR at teardown of test_drop_table[mysql_pymysql_conn] ___________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_drop_table[postgresql_psycopg2_engine] _______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ________ ERROR at teardown of test_drop_table[postgresql_psycopg2_conn] ________ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __________ ERROR at teardown of test_roundtrip[mysql_pymysql_engine] ___________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___________ ERROR at teardown of test_roundtrip[mysql_pymysql_conn] ____________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_roundtrip[postgresql_psycopg2_engine] ________ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ________ ERROR at teardown of test_roundtrip[postgresql_psycopg2_conn] _________ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _______ ERROR at teardown of test_execute_sql[mysql_pymysql_engine_iris] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ________ ERROR at teardown of test_execute_sql[mysql_pymysql_conn_iris] ________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_engine_iris] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_conn_iris] _____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_engine_iris] __ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ___ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_engine_iris] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_conn_iris] __ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_engine_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____________ ERROR at teardown of test_bigint[mysql_pymysql_engine] ____________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____________ ERROR at teardown of test_bigint[mysql_pymysql_conn] _____________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _________ ERROR at teardown of test_bigint[postgresql_psycopg2_engine] _________ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __________ ERROR at teardown of test_bigint[postgresql_psycopg2_conn] __________ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___ ERROR at teardown of test_default_date_load[mysql_pymysql_engine_types] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____ ERROR at teardown of test_default_date_load[mysql_pymysql_conn_types] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_engine_types] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_conn_types] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_engine] ____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_conn] _____ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_conn] __ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] _ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] __ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_date_parsing[mysql_pymysql_engine_types] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_date_parsing[mysql_pymysql_conn_types] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_date_parsing[postgresql_psycopg2_engine_types] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_date_parsing[postgresql_psycopg2_conn_types] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ___________ ERROR at teardown of test_datetime[mysql_pymysql_engine] ___________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ____________ ERROR at teardown of test_datetime[mysql_pymysql_conn] ____________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ________ ERROR at teardown of test_datetime[postgresql_psycopg2_engine] ________ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _________ ERROR at teardown of test_datetime[postgresql_psycopg2_conn] _________ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_engine] _________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s __________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_conn] __________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_engine] ______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_conn] _______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ________ ERROR at teardown of test_datetime_date[mysql_pymysql_engine] _________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _________ ERROR at teardown of test_datetime_date[mysql_pymysql_conn] __________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_datetime_date[postgresql_psycopg2_engine] ______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_datetime_date[postgresql_psycopg2_conn] _______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ________ ERROR at teardown of test_datetime_time[mysql_pymysql_engine] _________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _________ ERROR at teardown of test_datetime_time[mysql_pymysql_conn] __________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_datetime_time[postgresql_psycopg2_engine] ______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_datetime_time[postgresql_psycopg2_conn] _______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_engine] ______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_conn] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_engine] ___ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ____ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_conn] ____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _________ ERROR at teardown of test_nan_numeric[mysql_pymysql_engine] __________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s __________ ERROR at teardown of test_nan_numeric[mysql_pymysql_conn] ___________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_engine] _______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s _______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_conn] ________ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_engine] ________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_conn] _________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _____ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_engine] _____ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_conn] ______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s __________ ERROR at teardown of test_nan_string[mysql_pymysql_engine] __________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s ___________ ERROR at teardown of test_nan_string[mysql_pymysql_conn] ___________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_nan_string[postgresql_psycopg2_engine] _______ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ________ ERROR at teardown of test_nan_string[postgresql_psycopg2_conn] ________ 2563s self = 2563s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2563s connection = None, _has_events = None, _allow_revalidate = True 2563s _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def postgresql_psycopg2_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s td.versioned_importorskip("psycopg2") 2563s engine = sqlalchemy.create_engine( 2563s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2563s connection_factory = None, cursor_factory = None 2563s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2563s kwasync = {} 2563s 2563s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2563s """ 2563s Create a new database connection. 2563s 2563s The connection parameters can be specified as a string: 2563s 2563s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2563s 2563s or using a set of keyword arguments: 2563s 2563s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2563s 2563s Or as a mix of both. The basic connection parameters are: 2563s 2563s - *dbname*: the database name 2563s - *database*: the database name (only as keyword argument) 2563s - *user*: user name used to authenticate 2563s - *password*: password used to authenticate 2563s - *host*: database host address (defaults to UNIX socket if not provided) 2563s - *port*: connection port number (defaults to 5432 if not provided) 2563s 2563s Using the *connection_factory* parameter a different class or connections 2563s factory can be specified. It should be a callable object taking a dsn 2563s argument. 2563s 2563s Using the *cursor_factory* parameter, a new default cursor factory will be 2563s used by cursor(). 2563s 2563s Using *async*=True an asynchronous connection will be created. *async_* is 2563s a valid alias (for Python versions where ``async`` is a keyword). 2563s 2563s Any other keyword parameter will be passed to the underlying client 2563s library: the list of supported parameters depends on the library version. 2563s 2563s """ 2563s kwasync = {} 2563s if 'async' in kwargs: 2563s kwasync['async'] = kwargs.pop('async') 2563s if 'async_' in kwargs: 2563s kwasync['async_'] = kwargs.pop('async_') 2563s 2563s dsn = _ext.make_dsn(dsn, **kwargs) 2563s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2563s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2563s E Is the server running on that host and accepting TCP/IP connections? 2563s E 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2563s ______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_engine] _______ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s 2563s The above exception was the direct cause of the following exception: 2563s 2563s @pytest.fixture 2563s def mysql_pymysql_engine(): 2563s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2563s pymysql = td.versioned_importorskip("pymysql") 2563s engine = sqlalchemy.create_engine( 2563s "mysql+pymysql://root@localhost:3306/pandas", 2563s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2563s poolclass=sqlalchemy.pool.NullPool, 2563s ) 2563s yield engine 2563s > for view in get_all_views(engine): 2563s 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2563s return inspect(conn).get_view_names() 2563s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2563s ret = reg(subject) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2563s return Inspector._construct(Inspector._init_engine, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2563s init(self, bind) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2563s engine.connect().close() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2563s return self._connection_cls(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2563s Connection._handle_dbapi_exception_noconnection( 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2563s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2563s self._dbapi_connection = engine.raw_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s break 2563s except OSError as e: 2563s if e.errno == errno.EINTR: 2563s continue 2563s raise 2563s self.host_info = "socket %s:%d" % (self.host, self.port) 2563s if DEBUG: 2563s print("connected using socket") 2563s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2563s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2563s sock.settimeout(None) 2563s 2563s self._sock = sock 2563s self._rfile = sock.makefile("rb") 2563s self._next_seq_id = 0 2563s 2563s self._get_server_information() 2563s self._request_authentication() 2563s 2563s # Send "SET NAMES" query on init for: 2563s # - Ensure charaset (and collation) is set to the server. 2563s # - collation_id in handshake packet may be ignored. 2563s # - If collation is not specified, we don't know what is server's 2563s # default collation for the charset. For example, default collation 2563s # of utf8mb4 is: 2563s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2563s # - MySQL 8.0: utf8mb4_0900_ai_ci 2563s # 2563s # Reference: 2563s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2563s # - https://github.com/wagtail/wagtail/issues/9477 2563s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2563s self.set_character_set(self.charset, self.collation) 2563s 2563s if self.sql_mode is not None: 2563s c = self.cursor() 2563s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2563s c.close() 2563s 2563s if self.init_command is not None: 2563s c = self.cursor() 2563s c.execute(self.init_command) 2563s c.close() 2563s 2563s if self.autocommit_mode is not None: 2563s self.autocommit(self.autocommit_mode) 2563s except BaseException as e: 2563s self._rfile = None 2563s if sock is not None: 2563s try: 2563s sock.close() 2563s except: # noqa 2563s pass 2563s 2563s if isinstance(e, (OSError, IOError)): 2563s exc = err.OperationalError( 2563s CR.CR_CONN_HOST_ERROR, 2563s f"Can't connect to MySQL server on {self.host!r} ({e})", 2563s ) 2563s # Keep original exception and traceback to investigate error. 2563s exc.original_exception = e 2563s exc.traceback = traceback.format_exc() 2563s if DEBUG: 2563s print(exc.traceback) 2563s > raise exc 2563s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2563s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2563s _______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_conn] ________ 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2563s print("connected using unix_socket") 2563s else: 2563s kwargs = {} 2563s if self.bind_address is not None: 2563s kwargs["source_address"] = (self.bind_address, 0) 2563s while True: 2563s try: 2563s > sock = socket.create_connection( 2563s (self.host, self.port), self.connect_timeout, **kwargs 2563s ) 2563s 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3.13/socket.py:864: in create_connection 2563s raise exceptions[0] 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s address = ('localhost', 3306), timeout = 10, source_address = None 2563s 2563s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2563s source_address=None, *, all_errors=False): 2563s """Connect to *address* and return the socket object. 2563s 2563s Convenience function. Connect to *address* (a 2-tuple ``(host, 2563s port)``) and return the socket object. Passing the optional 2563s *timeout* parameter will set the timeout on the socket instance 2563s before attempting to connect. If no *timeout* is supplied, the 2563s global default timeout setting returned by :func:`getdefaulttimeout` 2563s is used. If *source_address* is set it must be a tuple of (host, port) 2563s for the socket to bind as a source address before making the connection. 2563s A host of '' or port 0 tells the OS to use the default. When a connection 2563s cannot be created, raises the last error if *all_errors* is False, 2563s and an ExceptionGroup of all errors if *all_errors* is True. 2563s """ 2563s 2563s host, port = address 2563s exceptions = [] 2563s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2563s af, socktype, proto, canonname, sa = res 2563s sock = None 2563s try: 2563s sock = socket(af, socktype, proto) 2563s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2563s sock.settimeout(timeout) 2563s if source_address: 2563s sock.bind(source_address) 2563s > sock.connect(sa) 2563s E ConnectionRefusedError: [Errno 111] Connection refused 2563s 2563s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2563s 2563s During handling of the above exception, another exception occurred: 2563s 2563s self = 2563s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2563s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2563s 2563s def __init__( 2563s self, 2563s engine: Engine, 2563s connection: Optional[PoolProxiedConnection] = None, 2563s _has_events: Optional[bool] = None, 2563s _allow_revalidate: bool = True, 2563s _allow_autobegin: bool = True, 2563s ): 2563s """Construct a new Connection.""" 2563s self.engine = engine 2563s self.dialect = dialect = engine.dialect 2563s 2563s if connection is None: 2563s try: 2563s > self._dbapi_connection = engine.raw_connection() 2563s 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2563s return self.pool.connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2563s return _ConnectionFairy._checkout(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2563s fairy = _ConnectionRecord.checkout(pool) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2563s rec = pool._do_get() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2563s return self._create_connection() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2563s return _ConnectionRecord(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2563s self.__connect() 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2563s with util.safe_reraise(): 2563s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2563s raise exc_value.with_traceback(exc_tb) 2563s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2563s self.dbapi_connection = connection = pool._invoke_creator(self) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2563s return dialect.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2563s return self.loaded_dbapi.connect(*cargs, **cparams) 2563s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2563s self.connect() 2563s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2563s 2563s self = , sock = None 2563s 2563s def connect(self, sock=None): 2563s self._closed = False 2563s try: 2563s if sock is None: 2563s if self.unix_socket: 2563s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2563s sock.settimeout(self.connect_timeout) 2563s sock.connect(self.unix_socket) 2563s self.host_info = "Localhost via UNIX socket" 2563s self._secure = True 2563s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_engine] ____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_conn] _____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _________ ERROR at teardown of test_transactions[mysql_pymysql_engine] _________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __________ ERROR at teardown of test_transactions[mysql_pymysql_conn] __________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ______ ERROR at teardown of test_transactions[postgresql_psycopg2_engine] ______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______ ERROR at teardown of test_transactions[postgresql_psycopg2_conn] _______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _____ ERROR at teardown of test_transaction_rollback[mysql_pymysql_engine] _____ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ______ ERROR at teardown of test_transaction_rollback[mysql_pymysql_conn] ______ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_engine] __ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ___ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_conn] ___ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ___ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_engine] ____ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_conn] _____ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_conn] __ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________ ERROR at teardown of test_dtype[mysql_pymysql_engine] _____________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____________ ERROR at teardown of test_dtype[mysql_pymysql_conn] ______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _________ ERROR at teardown of test_dtype[postgresql_psycopg2_engine] __________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __________ ERROR at teardown of test_dtype[postgresql_psycopg2_conn] ___________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _________ ERROR at teardown of test_notna_dtype[mysql_pymysql_engine] __________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __________ ERROR at teardown of test_notna_dtype[mysql_pymysql_conn] ___________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_engine] _______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_conn] ________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______ ERROR at teardown of test_double_precision[mysql_pymysql_engine] _______ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ________ ERROR at teardown of test_double_precision[mysql_pymysql_conn] ________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____ ERROR at teardown of test_double_precision[postgresql_psycopg2_engine] ____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _____ ERROR at teardown of test_double_precision[postgresql_psycopg2_conn] _____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_engine] ___ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_conn] ____ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______ ERROR at teardown of test_temporary_table[mysql_pymysql_engine] ________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ________ ERROR at teardown of test_temporary_table[mysql_pymysql_conn] _________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_engine] _____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_conn] ______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ________ ERROR at teardown of test_invalid_engine[mysql_pymysql_engine] ________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _________ ERROR at teardown of test_invalid_engine[mysql_pymysql_conn] _________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_engine] _____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_conn] ______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_engine] ____ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_conn] _____ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_conn] __ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_engine] ______ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_conn] _______ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_engine] ___ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_conn] ____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _________ ERROR at teardown of test_options_auto[mysql_pymysql_engine] _________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __________ ERROR at teardown of test_options_auto[mysql_pymysql_conn] __________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ______ ERROR at teardown of test_options_auto[postgresql_psycopg2_engine] ______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______ ERROR at teardown of test_options_auto[postgresql_psycopg2_conn] _______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_engine] ____ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_conn] _____ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_conn] __ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def mysql_pymysql_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s pymysql = td.versioned_importorskip("pymysql") 2564s engine = sqlalchemy.create_engine( 2564s "mysql+pymysql://root@localhost:3306/pandas", 2564s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ ERROR at teardown of test_psycopg2_schema_support _______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______________ ERROR at teardown of test_self_join_date_columns _______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s @pytest.fixture 2564s def postgresql_psycopg2_engine(): 2564s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2564s td.versioned_importorskip("psycopg2") 2564s engine = sqlalchemy.create_engine( 2564s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2564s poolclass=sqlalchemy.pool.NullPool, 2564s ) 2564s yield engine 2564s > for view in get_all_views(engine): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2564s return inspect(conn).get_view_names() 2564s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2564s ret = reg(subject) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2564s return Inspector._construct(Inspector._init_engine, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2564s init(self, bind) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2564s engine.connect().close() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s =================================== FAILURES =================================== 2564s _________________ test_dataframe_to_sql[mysql_pymysql_engine] __________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_dataframe_to_sql(conn, test_frame1, request): 2564s # GH 51086 if conn is sqlite_engine 2564s conn = request.getfixturevalue(conn) 2564s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2564s return func(*args, **kwargs) 2564s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2564s return sql.to_sql( 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2564s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __________________ test_dataframe_to_sql[mysql_pymysql_conn] ___________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_dataframe_to_sql(conn, test_frame1, request): 2564s # GH 51086 if conn is sqlite_engine 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ______________ test_dataframe_to_sql[postgresql_psycopg2_engine] _______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_dataframe_to_sql(conn, test_frame1, request): 2564s # GH 51086 if conn is sqlite_engine 2564s conn = request.getfixturevalue(conn) 2564s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2564s return func(*args, **kwargs) 2564s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2564s return sql.to_sql( 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2564s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______________ test_dataframe_to_sql[postgresql_psycopg2_conn] ________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_dataframe_to_sql(conn, test_frame1, request): 2564s # GH 51086 if conn is sqlite_engine 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ test_dataframe_to_sql_empty[mysql_pymysql_engine] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2564s if conn == "postgresql_adbc_conn": 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="postgres ADBC driver cannot insert index with null type", 2564s strict=True, 2564s ) 2564s ) 2564s # GH 51086 if conn is sqlite_engine 2564s conn = request.getfixturevalue(conn) 2564s empty_df = test_frame1.iloc[:0] 2564s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2564s return func(*args, **kwargs) 2564s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2564s return sql.to_sql( 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2564s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______________ test_dataframe_to_sql_empty[mysql_pymysql_conn] ________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2564s if conn == "postgresql_adbc_conn": 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="postgres ADBC driver cannot insert index with null type", 2564s strict=True, 2564s ) 2564s ) 2564s # GH 51086 if conn is sqlite_engine 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_dataframe_to_sql_empty[postgresql_psycopg2_engine] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2564s if conn == "postgresql_adbc_conn": 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="postgres ADBC driver cannot insert index with null type", 2564s strict=True, 2564s ) 2564s ) 2564s # GH 51086 if conn is sqlite_engine 2564s conn = request.getfixturevalue(conn) 2564s empty_df = test_frame1.iloc[:0] 2564s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2564s return func(*args, **kwargs) 2564s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2564s return sql.to_sql( 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2564s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________ test_dataframe_to_sql_empty[postgresql_psycopg2_conn] _____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2564s if conn == "postgresql_adbc_conn": 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="postgres ADBC driver cannot insert index with null type", 2564s strict=True, 2564s ) 2564s ) 2564s # GH 51086 if conn is sqlite_engine 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________________ test_to_sql[None-mysql_pymysql_engine] ____________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = None 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("method", [None, "multi"]) 2564s def test_to_sql(conn, method, test_frame1, request): 2564s if method == "multi" and "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'method' not implemented for ADBC drivers", strict=True 2564s ) 2564s ) 2564s 2564s conn = request.getfixturevalue(conn) 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____________________ test_to_sql[None-mysql_pymysql_conn] _____________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn', method = None 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("method", [None, "multi"]) 2564s def test_to_sql(conn, method, test_frame1, request): 2564s if method == "multi" and "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'method' not implemented for ADBC drivers", strict=True 2564s ) 2564s ) 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _________________ test_to_sql[None-postgresql_psycopg2_engine] _________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s method = None 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("method", [None, "multi"]) 2564s def test_to_sql(conn, method, test_frame1, request): 2564s if method == "multi" and "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'method' not implemented for ADBC drivers", strict=True 2564s ) 2564s ) 2564s 2564s conn = request.getfixturevalue(conn) 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __________________ test_to_sql[None-postgresql_psycopg2_conn] __________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn', method = None 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("method", [None, "multi"]) 2564s def test_to_sql(conn, method, test_frame1, request): 2564s if method == "multi" and "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'method' not implemented for ADBC drivers", strict=True 2564s ) 2564s ) 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ___________________ test_to_sql[multi-mysql_pymysql_engine] ____________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = 'multi' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("method", [None, "multi"]) 2564s def test_to_sql(conn, method, test_frame1, request): 2564s if method == "multi" and "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'method' not implemented for ADBC drivers", strict=True 2564s ) 2564s ) 2564s 2564s conn = request.getfixturevalue(conn) 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____________________ test_to_sql[multi-mysql_pymysql_conn] _____________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn', method = 'multi' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("method", [None, "multi"]) 2564s def test_to_sql(conn, method, test_frame1, request): 2564s if method == "multi" and "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'method' not implemented for ADBC drivers", strict=True 2564s ) 2564s ) 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ________________ test_to_sql[multi-postgresql_psycopg2_engine] _________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s method = 'multi' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("method", [None, "multi"]) 2564s def test_to_sql(conn, method, test_frame1, request): 2564s if method == "multi" and "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'method' not implemented for ADBC drivers", strict=True 2564s ) 2564s ) 2564s 2564s conn = request.getfixturevalue(conn) 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _________________ test_to_sql[multi-postgresql_psycopg2_conn] __________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn', method = 'multi' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("method", [None, "multi"]) 2564s def test_to_sql(conn, method, test_frame1, request): 2564s if method == "multi" and "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'method' not implemented for ADBC drivers", strict=True 2564s ) 2564s ) 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ test_to_sql_exist[replace-1-mysql_pymysql_engine] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'replace' 2564s num_row_coef = 1 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2564s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2564s conn = request.getfixturevalue(conn) 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______________ test_to_sql_exist[replace-1-mysql_pymysql_conn] ________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn', mode = 'replace', num_row_coef = 1 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2564s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_to_sql_exist[replace-1-postgresql_psycopg2_engine] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s mode = 'replace', num_row_coef = 1 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2564s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2564s conn = request.getfixturevalue(conn) 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________ test_to_sql_exist[replace-1-postgresql_psycopg2_conn] _____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn', mode = 'replace', num_row_coef = 1 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2564s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______________ test_to_sql_exist[append-2-mysql_pymysql_engine] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'append' 2564s num_row_coef = 2 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2564s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2564s conn = request.getfixturevalue(conn) 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ________________ test_to_sql_exist[append-2-mysql_pymysql_conn] ________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn', mode = 'append', num_row_coef = 2 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2564s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____________ test_to_sql_exist[append-2-postgresql_psycopg2_engine] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s mode = 'append', num_row_coef = 2 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2564s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2564s conn = request.getfixturevalue(conn) 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _____________ test_to_sql_exist[append-2-postgresql_psycopg2_conn] _____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn', mode = 'append', num_row_coef = 2 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2564s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _________________ test_to_sql_exist_fail[mysql_pymysql_engine] _________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_to_sql_exist_fail(conn, test_frame1, request): 2564s conn = request.getfixturevalue(conn) 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __________________ test_to_sql_exist_fail[mysql_pymysql_conn] __________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_to_sql_exist_fail(conn, test_frame1, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ______________ test_to_sql_exist_fail[postgresql_psycopg2_engine] ______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_to_sql_exist_fail(conn, test_frame1, request): 2564s conn = request.getfixturevalue(conn) 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______________ test_to_sql_exist_fail[postgresql_psycopg2_conn] _______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_to_sql_exist_fail(conn, test_frame1, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______________ test_read_iris_query[mysql_pymysql_engine_iris] ________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ________________ test_read_iris_query[mysql_pymysql_conn_iris] _________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____________ test_read_iris_query[postgresql_psycopg2_engine_iris] _____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _____________ test_read_iris_query[postgresql_psycopg2_conn_iris] ______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __________ test_read_iris_query_chunksize[mysql_pymysql_engine_iris] ___________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query_chunksize(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_read_iris_query_chunksize[mysql_pymysql_conn_iris] ____________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query_chunksize(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______ test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] ________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query_chunksize(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ________ test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query_chunksize(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __ test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] ___ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_query_expression_with_parameter(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___ test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] ____ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_query_expression_with_parameter(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_query_expression_with_parameter(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_query_expression_with_parameter(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____ test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _____ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s 2564s for db, query in sql_strings["read_parameters"].items(): 2564s if db in conn: 2564s break 2564s else: 2564s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____ test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] ______ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s 2564s for db, query in sql_strings["read_parameters"].items(): 2564s if db in conn: 2564s break 2564s else: 2564s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] __ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s 2564s for db, query in sql_strings["read_parameters"].items(): 2564s if db in conn: 2564s break 2564s else: 2564s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __ test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] ___ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'chunksize' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s 2564s for db, query in sql_strings["read_parameters"].items(): 2564s if db in conn: 2564s break 2564s else: 2564s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______________ test_read_iris_table[mysql_pymysql_engine_iris] ________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_table(conn, request): 2564s # GH 51015 if conn = sqlite_iris_str 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ________________ test_read_iris_table[mysql_pymysql_conn_iris] _________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_table(conn, request): 2564s # GH 51015 if conn = sqlite_iris_str 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____________ test_read_iris_table[postgresql_psycopg2_engine_iris] _____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_table(conn, request): 2564s # GH 51015 if conn = sqlite_iris_str 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _____________ test_read_iris_table[postgresql_psycopg2_conn_iris] ______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_table(conn, request): 2564s # GH 51015 if conn = sqlite_iris_str 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __________ test_read_iris_table_chunksize[mysql_pymysql_engine_iris] ___________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_table_chunksize(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_read_iris_table_chunksize[mysql_pymysql_conn_iris] ____________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_table_chunksize(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______ test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] ________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_table_chunksize(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ________ test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2564s def test_read_iris_table_chunksize(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __________________ test_to_sql_callable[mysql_pymysql_engine] __________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2564s def test_to_sql_callable(conn, test_frame1, request): 2564s conn = request.getfixturevalue(conn) 2564s 2564s check = [] # used to double check function below is really being used 2564s 2564s def sample(pd_table, conn, keys, data_iter): 2564s check.append(1) 2564s data = [dict(zip(keys, row)) for row in data_iter] 2564s conn.execute(pd_table.table.insert(), data) 2564s 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________________ test_to_sql_callable[mysql_pymysql_conn] ___________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2564s def test_to_sql_callable(conn, test_frame1, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______________ test_to_sql_callable[postgresql_psycopg2_engine] _______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2564s def test_to_sql_callable(conn, test_frame1, request): 2564s conn = request.getfixturevalue(conn) 2564s 2564s check = [] # used to double check function below is really being used 2564s 2564s def sample(pd_table, conn, keys, data_iter): 2564s check.append(1) 2564s data = [dict(zip(keys, row)) for row in data_iter] 2564s conn.execute(pd_table.table.insert(), data) 2564s 2564s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ________________ test_to_sql_callable[postgresql_psycopg2_conn] ________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2564s def test_to_sql_callable(conn, test_frame1, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ___________ test_default_type_conversion[mysql_pymysql_engine_types] ___________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_default_type_conversion(conn, request): 2564s conn_name = conn 2564s if conn_name == "sqlite_buildin_types": 2564s request.applymarker( 2564s pytest.mark.xfail( 2564s reason="sqlite_buildin connection does not implement read_sql_table" 2564s ) 2564s ) 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____________ test_default_type_conversion[mysql_pymysql_conn_types] ____________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_default_type_conversion(conn, request): 2564s conn_name = conn 2564s if conn_name == "sqlite_buildin_types": 2564s request.applymarker( 2564s pytest.mark.xfail( 2564s reason="sqlite_buildin connection does not implement read_sql_table" 2564s ) 2564s ) 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ________ test_default_type_conversion[postgresql_psycopg2_engine_types] ________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_default_type_conversion(conn, request): 2564s conn_name = conn 2564s if conn_name == "sqlite_buildin_types": 2564s request.applymarker( 2564s pytest.mark.xfail( 2564s reason="sqlite_buildin connection does not implement read_sql_table" 2564s ) 2564s ) 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _________ test_default_type_conversion[postgresql_psycopg2_conn_types] _________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_default_type_conversion(conn, request): 2564s conn_name = conn 2564s if conn_name == "sqlite_buildin_types": 2564s request.applymarker( 2564s pytest.mark.xfail( 2564s reason="sqlite_buildin connection does not implement read_sql_table" 2564s ) 2564s ) 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __________________ test_read_procedure[mysql_pymysql_engine] ___________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", mysql_connectable) 2564s def test_read_procedure(conn, request): 2564s conn = request.getfixturevalue(conn) 2564s 2564s # GH 7324 2564s # Although it is more an api test, it is added to the 2564s # mysql tests as sqlite does not have stored procedures 2564s from sqlalchemy import text 2564s from sqlalchemy.engine import Engine 2564s 2564s df = DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3]}) 2564s > df.to_sql(name="test_frame", con=conn, index=False) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1253: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2564s return func(*args, **kwargs) 2564s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2564s return sql.to_sql( 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2564s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________________ test_read_procedure[mysql_pymysql_conn] ____________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", mysql_connectable) 2564s def test_read_procedure(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1244: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] ____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s expected_count = 2 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", postgresql_connectable) 2564s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2564s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2564s # GH 8953 2564s # Example in io.rst found under _io.sql.method 2564s # not available in sqlite, mysql 2564s def psql_insert_copy(table, conn, keys, data_iter): 2564s # gets a DBAPI connection that can provide a cursor 2564s dbapi_conn = conn.connection 2564s with dbapi_conn.cursor() as cur: 2564s s_buf = StringIO() 2564s writer = csv.writer(s_buf) 2564s writer.writerows(data_iter) 2564s s_buf.seek(0) 2564s 2564s columns = ", ".join([f'"{k}"' for k in keys]) 2564s if table.schema: 2564s table_name = f"{table.schema}.{table.name}" 2564s else: 2564s table_name = table.name 2564s 2564s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2564s cur.copy_expert(sql=sql_query, file=s_buf) 2564s return expected_count 2564s 2564s conn = request.getfixturevalue(conn) 2564s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2564s > result_count = expected.to_sql( 2564s name="test_frame", con=conn, index=False, method=psql_insert_copy 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2564s return func(*args, **kwargs) 2564s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2564s return sql.to_sql( 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2564s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn', expected_count = 2 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", postgresql_connectable) 2564s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2564s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2564s # GH 8953 2564s # Example in io.rst found under _io.sql.method 2564s # not available in sqlite, mysql 2564s def psql_insert_copy(table, conn, keys, data_iter): 2564s # gets a DBAPI connection that can provide a cursor 2564s dbapi_conn = conn.connection 2564s with dbapi_conn.cursor() as cur: 2564s s_buf = StringIO() 2564s writer = csv.writer(s_buf) 2564s writer.writerows(data_iter) 2564s s_buf.seek(0) 2564s 2564s columns = ", ".join([f'"{k}"' for k in keys]) 2564s if table.schema: 2564s table_name = f"{table.schema}.{table.name}" 2564s else: 2564s table_name = table.name 2564s 2564s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2564s cur.copy_expert(sql=sql_query, file=s_buf) 2564s return expected_count 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s expected_count = 'Success!' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", postgresql_connectable) 2564s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2564s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2564s # GH 8953 2564s # Example in io.rst found under _io.sql.method 2564s # not available in sqlite, mysql 2564s def psql_insert_copy(table, conn, keys, data_iter): 2564s # gets a DBAPI connection that can provide a cursor 2564s dbapi_conn = conn.connection 2564s with dbapi_conn.cursor() as cur: 2564s s_buf = StringIO() 2564s writer = csv.writer(s_buf) 2564s writer.writerows(data_iter) 2564s s_buf.seek(0) 2564s 2564s columns = ", ".join([f'"{k}"' for k in keys]) 2564s if table.schema: 2564s table_name = f"{table.schema}.{table.name}" 2564s else: 2564s table_name = table.name 2564s 2564s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2564s cur.copy_expert(sql=sql_query, file=s_buf) 2564s return expected_count 2564s 2564s conn = request.getfixturevalue(conn) 2564s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2564s > result_count = expected.to_sql( 2564s name="test_frame", con=conn, index=False, method=psql_insert_copy 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2564s return func(*args, **kwargs) 2564s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2564s return sql.to_sql( 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2564s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] __ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn', expected_count = 'Success!' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", postgresql_connectable) 2564s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2564s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2564s # GH 8953 2564s # Example in io.rst found under _io.sql.method 2564s # not available in sqlite, mysql 2564s def psql_insert_copy(table, conn, keys, data_iter): 2564s # gets a DBAPI connection that can provide a cursor 2564s dbapi_conn = conn.connection 2564s with dbapi_conn.cursor() as cur: 2564s s_buf = StringIO() 2564s writer = csv.writer(s_buf) 2564s writer.writerows(data_iter) 2564s s_buf.seek(0) 2564s 2564s columns = ", ".join([f'"{k}"' for k in keys]) 2564s if table.schema: 2564s table_name = f"{table.schema}.{table.name}" 2564s else: 2564s table_name = table.name 2564s 2564s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2564s cur.copy_expert(sql=sql_query, file=s_buf) 2564s return expected_count 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ___ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] ___ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", postgresql_connectable) 2564s def test_insertion_method_on_conflict_do_nothing(conn, request): 2564s # GH 15988: Example in to_sql docstring 2564s conn = request.getfixturevalue(conn) 2564s 2564s from sqlalchemy.dialects.postgresql import insert 2564s from sqlalchemy.engine import Engine 2564s from sqlalchemy.sql import text 2564s 2564s def insert_on_conflict(table, conn, keys, data_iter): 2564s data = [dict(zip(keys, row)) for row in data_iter] 2564s stmt = ( 2564s insert(table.table) 2564s .values(data) 2564s .on_conflict_do_nothing(index_elements=["a"]) 2564s ) 2564s result = conn.execute(stmt) 2564s return result.rowcount 2564s 2564s create_sql = text( 2564s """ 2564s CREATE TABLE test_insert_conflict ( 2564s a integer PRIMARY KEY, 2564s b numeric, 2564s c text 2564s ); 2564s """ 2564s ) 2564s if isinstance(conn, Engine): 2564s > with conn.connect() as con: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1347: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] ____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", postgresql_connectable) 2564s def test_insertion_method_on_conflict_do_nothing(conn, request): 2564s # GH 15988: Example in to_sql docstring 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1321: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ___________ test_to_sql_on_public_schema[postgresql_psycopg2_engine] ___________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_to_sql_on_public_schema(conn, request): 2564s if "sqlite" in conn or "mysql" in conn: 2564s request.applymarker( 2564s pytest.mark.xfail( 2564s reason="test for public schema only specific to postgresql" 2564s ) 2564s ) 2564s 2564s conn = request.getfixturevalue(conn) 2564s 2564s test_data = DataFrame([[1, 2.1, "a"], [2, 3.1, "b"]], columns=list("abc")) 2564s > test_data.to_sql( 2564s name="test_public_schema", 2564s con=conn, 2564s if_exists="append", 2564s index=False, 2564s schema="public", 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1388: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2564s return func(*args, **kwargs) 2564s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2564s return sql.to_sql( 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2564s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________ test_to_sql_on_public_schema[postgresql_psycopg2_conn] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_to_sql_on_public_schema(conn, request): 2564s if "sqlite" in conn or "mysql" in conn: 2564s request.applymarker( 2564s pytest.mark.xfail( 2564s reason="test for public schema only specific to postgresql" 2564s ) 2564s ) 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1385: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ________ test_insertion_method_on_conflict_update[mysql_pymysql_engine] ________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", mysql_connectable) 2564s def test_insertion_method_on_conflict_update(conn, request): 2564s # GH 14553: Example in to_sql docstring 2564s conn = request.getfixturevalue(conn) 2564s 2564s from sqlalchemy.dialects.mysql import insert 2564s from sqlalchemy.engine import Engine 2564s from sqlalchemy.sql import text 2564s 2564s def insert_on_conflict(table, conn, keys, data_iter): 2564s data = [dict(zip(keys, row)) for row in data_iter] 2564s stmt = insert(table.table).values(data) 2564s stmt = stmt.on_duplicate_key_update(b=stmt.inserted.b, c=stmt.inserted.c) 2564s result = conn.execute(stmt) 2564s return result.rowcount 2564s 2564s create_sql = text( 2564s """ 2564s CREATE TABLE test_insert_conflict ( 2564s a INT PRIMARY KEY, 2564s b FLOAT, 2564s c VARCHAR(10) 2564s ); 2564s """ 2564s ) 2564s if isinstance(conn, Engine): 2564s > with conn.connect() as con: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1426: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _________ test_insertion_method_on_conflict_update[mysql_pymysql_conn] _________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", mysql_connectable) 2564s def test_insertion_method_on_conflict_update(conn, request): 2564s # GH 14553: Example in to_sql docstring 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1403: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____________ test_read_view_postgres[postgresql_psycopg2_engine] ______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", postgresql_connectable) 2564s def test_read_view_postgres(conn, request): 2564s # GH 52969 2564s conn = request.getfixturevalue(conn) 2564s 2564s from sqlalchemy.engine import Engine 2564s from sqlalchemy.sql import text 2564s 2564s table_name = f"group_{uuid.uuid4().hex}" 2564s view_name = f"group_view_{uuid.uuid4().hex}" 2564s 2564s sql_stmt = text( 2564s f""" 2564s CREATE TABLE {table_name} ( 2564s group_id INTEGER, 2564s name TEXT 2564s ); 2564s INSERT INTO {table_name} VALUES 2564s (1, 'name'); 2564s CREATE VIEW {view_name} 2564s AS 2564s SELECT * FROM {table_name}; 2564s """ 2564s ) 2564s if isinstance(conn, Engine): 2564s > with conn.connect() as con: 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1478: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ test_read_view_postgres[postgresql_psycopg2_conn] _______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", postgresql_connectable) 2564s def test_read_view_postgres(conn, request): 2564s # GH 52969 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1456: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ___________ test_read_sql_iris_parameter[mysql_pymysql_engine_iris] ____________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_sql_iris_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'params' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____________ test_read_sql_iris_parameter[mysql_pymysql_conn_iris] _____________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_sql_iris_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'params' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ________ test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_sql_iris_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'params' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _________ test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] __________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_sql_iris_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'params' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ________ test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'params' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _________ test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] __________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'params' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____ test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] ______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'params' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______ test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_iris' 2564s request = > 2564s sql_strings = {'read_named_parameters': {'mysql': '\n SELECT * FROM iris WHERE\n `Name`=%(name)s AND `...LECT * FROM iris WHERE "Name"=%s AND "SepalLength"=%s', 'sqlite': 'SELECT * FROM iris WHERE Name=? AND SepalLength=?'}} 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail( 2564s reason="'params' not implemented for ADBC drivers", 2564s strict=True, 2564s ) 2564s ) 2564s 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ test_api_read_sql_view[mysql_pymysql_engine_iris] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_read_sql_view(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______________ test_api_read_sql_view[mysql_pymysql_conn_iris] ________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_read_sql_view(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_api_read_sql_view[postgresql_psycopg2_engine_iris] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_read_sql_view(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________ test_api_read_sql_view[postgresql_psycopg2_conn_iris] _____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_read_sql_view(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _____ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_read_sql_with_chunksize_no_result(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] ______ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_read_sql_with_chunksize_no_result(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] __ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_read_sql_with_chunksize_no_result(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] ___ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_read_sql_with_chunksize_no_result(conn, request): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________________ test_api_to_sql[mysql_pymysql_engine] _____________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql(conn, request, test_frame1): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame1", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____________________ test_api_to_sql[mysql_pymysql_conn] ______________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql(conn, request, test_frame1): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _________________ test_api_to_sql[postgresql_psycopg2_engine] __________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql(conn, request, test_frame1): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame1", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __________________ test_api_to_sql[postgresql_psycopg2_conn] ___________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql(conn, request, test_frame1): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __________________ test_api_to_sql_fail[mysql_pymysql_engine] __________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_fail(conn, request, test_frame1): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame2", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________________ test_api_to_sql_fail[mysql_pymysql_conn] ___________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_fail(conn, request, test_frame1): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______________ test_api_to_sql_fail[postgresql_psycopg2_engine] _______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_fail(conn, request, test_frame1): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame2", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ________________ test_api_to_sql_fail[postgresql_psycopg2_conn] ________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_fail(conn, request, test_frame1): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ________________ test_api_to_sql_replace[mysql_pymysql_engine] _________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_replace(conn, request, test_frame1): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame3", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _________________ test_api_to_sql_replace[mysql_pymysql_conn] __________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_replace(conn, request, test_frame1): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____________ test_api_to_sql_replace[postgresql_psycopg2_engine] ______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_replace(conn, request, test_frame1): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame3", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ test_api_to_sql_replace[postgresql_psycopg2_conn] _______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_replace(conn, request, test_frame1): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _________________ test_api_to_sql_append[mysql_pymysql_engine] _________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_append(conn, request, test_frame1): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame4", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __________________ test_api_to_sql_append[mysql_pymysql_conn] __________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_append(conn, request, test_frame1): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ______________ test_api_to_sql_append[postgresql_psycopg2_engine] ______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_append(conn, request, test_frame1): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame4", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______________ test_api_to_sql_append[postgresql_psycopg2_conn] _______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_append(conn, request, test_frame1): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ test_api_to_sql_type_mapping[mysql_pymysql_engine] ______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s test_frame3 = index A B 2564s 0 2000-01-03 00:00:00 2147483647 -1.987670 2564s 1 2000-01-04 00:00:00 -29 -0.041232 2564s 2 2000-01-05 00:00:00 20000 0.731168 2564s 3 2000-01-06 00:00:00 -290867 1.567621 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame5", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______________ test_api_to_sql_type_mapping[mysql_pymysql_conn] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s test_frame3 = index A B 2564s 0 2000-01-03 00:00:00 2147483647 -1.987670 2564s 1 2000-01-04 00:00:00 -29 -0.041232 2564s 2 2000-01-05 00:00:00 20000 0.731168 2564s 3 2000-01-06 00:00:00 -290867 1.567621 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_api_to_sql_type_mapping[postgresql_psycopg2_engine] ___________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s test_frame3 = index A B 2564s 0 2000-01-03 00:00:00 2147483647 -1.987670 2564s 1 2000-01-04 00:00:00 -29 -0.041232 2564s 2 2000-01-05 00:00:00 20000 0.731168 2564s 3 2000-01-06 00:00:00 -290867 1.567621 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame5", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________ test_api_to_sql_type_mapping[postgresql_psycopg2_conn] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s test_frame3 = index A B 2564s 0 2000-01-03 00:00:00 2147483647 -1.987670 2564s 1 2000-01-04 00:00:00 -29 -0.041232 2564s 2 2000-01-05 00:00:00 20000 0.731168 2564s 3 2000-01-06 00:00:00 -290867 1.567621 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _________________ test_api_to_sql_series[mysql_pymysql_engine] _________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_series(conn, request): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_series", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __________________ test_api_to_sql_series[mysql_pymysql_conn] __________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_series(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ______________ test_api_to_sql_series[postgresql_psycopg2_engine] ______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_series(conn, request): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_series", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______________ test_api_to_sql_series[postgresql_psycopg2_conn] _______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_series(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ___________________ test_api_roundtrip[mysql_pymysql_engine] ___________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_roundtrip(conn, request, test_frame1): 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame_roundtrip", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____________________ test_api_roundtrip[mysql_pymysql_conn] ____________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_roundtrip(conn, request, test_frame1): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ________________ test_api_roundtrip[postgresql_psycopg2_engine] ________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_roundtrip(conn, request, test_frame1): 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame_roundtrip", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _________________ test_api_roundtrip[postgresql_psycopg2_conn] _________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_roundtrip(conn, request, test_frame1): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ test_api_roundtrip_chunksize[mysql_pymysql_engine] ______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame_roundtrip", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______________ test_api_roundtrip_chunksize[mysql_pymysql_conn] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_api_roundtrip_chunksize[postgresql_psycopg2_engine] ___________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_frame_roundtrip", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________ test_api_roundtrip_chunksize[postgresql_psycopg2_conn] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s test_frame1 = index A B C D 2564s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2564s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______________ test_api_execute_sql[mysql_pymysql_engine_iris] ________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_execute_sql(conn, request): 2564s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ________________ test_api_execute_sql[mysql_pymysql_conn_iris] _________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_execute_sql(conn, request): 2564s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2564s create_and_load_iris(mysql_pymysql_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____________ test_api_execute_sql[postgresql_psycopg2_engine_iris] _____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_execute_sql(conn, request): 2564s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _____________ test_api_execute_sql[postgresql_psycopg2_conn_iris] ______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_iris' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_iris) 2564s def test_api_execute_sql(conn, request): 2564s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2564s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2564s with conn.begin() as con: 2564s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2564s return next(self.gen) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2564s with self.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ test_api_date_parsing[mysql_pymysql_engine_types] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_api_date_parsing(conn, request): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______________ test_api_date_parsing[mysql_pymysql_conn_types] ________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_api_date_parsing(conn, request): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_api_date_parsing[postgresql_psycopg2_engine_types] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_api_date_parsing(conn, request): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________ test_api_date_parsing[postgresql_psycopg2_conn_types] _____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_api_date_parsing(conn, request): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = , text = 'SELECT * FROM types' 2564s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2564s error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2564s error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2564s error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2564s error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2564s error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2564s error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2564s error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = 2564s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2564s error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'ignore' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'raise' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s read_sql = , text = 'types' 2564s mode = 'sqlalchemy', error = 'coerce' 2564s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2564s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2564s 1 first 2000-01-04 00:00:00 ... NaN NaN 2564s 2564s [2 rows x 9 columns] 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2564s @pytest.mark.parametrize( 2564s "read_sql, text, mode", 2564s [ 2564s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2564s (sql.read_sql, "types", ("sqlalchemy")), 2564s ( 2564s sql.read_sql_query, 2564s "SELECT * FROM types", 2564s ("sqlalchemy", "fallback"), 2564s ), 2564s (sql.read_sql_table, "types", ("sqlalchemy")), 2564s ], 2564s ) 2564s def test_api_custom_dateparsing_error( 2564s conn, request, read_sql, text, mode, error, types_data_frame 2564s ): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _____________ test_api_date_and_index[mysql_pymysql_engine_types] ______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_engine_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_api_date_and_index(conn, request): 2564s # Test case where same column appears in parse_date and index_col 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ______________ test_api_date_and_index[mysql_pymysql_conn_types] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_api_date_and_index(conn, request): 2564s # Test case where same column appears in parse_date and index_col 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2564s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __________ test_api_date_and_index[postgresql_psycopg2_engine_types] ___________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_engine_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_api_date_and_index(conn, request): 2564s # Test case where same column appears in parse_date and index_col 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ___________ test_api_date_and_index[postgresql_psycopg2_conn_types] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn_types' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable_types) 2564s def test_api_date_and_index(conn, request): 2564s # Test case where same column appears in parse_date and index_col 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2564s fixturedef = request._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2564s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2564s with conn.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ___________________ test_api_timedelta[mysql_pymysql_engine] ___________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_timedelta(conn, request): 2564s # see #6921 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_timedelta", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ____________________ test_api_timedelta[mysql_pymysql_conn] ____________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_timedelta(conn, request): 2564s # see #6921 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ________________ test_api_timedelta[postgresql_psycopg2_engine] ________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_timedelta(conn, request): 2564s # see #6921 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_timedelta", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _________________ test_api_timedelta[postgresql_psycopg2_conn] _________________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_timedelta(conn, request): 2564s # see #6921 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ________________ test_api_complex_raises[mysql_pymysql_engine] _________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_complex_raises(conn, request): 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s df = DataFrame({"a": [1 + 1j, 2j]}) 2564s 2564s if "adbc" in conn_name: 2564s msg = "datatypes not supported" 2564s else: 2564s msg = "Complex datatypes not supported" 2564s with pytest.raises(ValueError, match=msg): 2564s > assert df.to_sql("test_complex", con=conn) is None 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2564s return func(*args, **kwargs) 2564s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2564s return sql.to_sql( 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2564s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _________________ test_api_complex_raises[mysql_pymysql_conn] __________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_complex_raises(conn, request): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _____________ test_api_complex_raises[postgresql_psycopg2_engine] ______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_complex_raises(conn, request): 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s df = DataFrame({"a": [1 + 1j, 2j]}) 2564s 2564s if "adbc" in conn_name: 2564s msg = "datatypes not supported" 2564s else: 2564s msg = "Complex datatypes not supported" 2564s with pytest.raises(ValueError, match=msg): 2564s > assert df.to_sql("test_complex", con=conn) is None 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2564s return func(*args, **kwargs) 2564s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2564s return sql.to_sql( 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2564s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ test_api_complex_raises[postgresql_psycopg2_conn] _______________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_complex_raises(conn, request): 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _______ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s index_name = None, index_label = None, expected = 'index' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] ________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s index_name = None, index_label = None, expected = 'index' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] ____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s index_name = None, index_label = None, expected = 'index' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _____ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s index_name = None, index_label = None, expected = 'index' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s index_name = None, index_label = 'other_label', expected = 'other_label' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s index_name = None, index_label = 'other_label', expected = 'other_label' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s index_name = None, index_label = 'other_label', expected = 'other_label' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s index_name = None, index_label = 'other_label', expected = 'other_label' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s index_name = 'index_name', index_label = None, expected = 'index_name' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] __ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s index_name = 'index_name', index_label = None, expected = 'index_name' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s index_name = 'index_name', index_label = None, expected = 'index_name' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s index_name = 'index_name', index_label = None, expected = 'index_name' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] __________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s index_name = 0, index_label = None, expected = '0' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] ___________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s index_name = 0, index_label = None, expected = '0' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s index_name = 0, index_label = None, expected = '0' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ________ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] ________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s index_name = 0, index_label = None, expected = '0' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s __________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] __________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s index_name = None, index_label = 0, expected = '0' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] ___________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s index_name = None, index_label = 0, expected = '0' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s index_name = None, index_label = 0, expected = '0' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ________ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] ________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s index_name = None, index_label = 0, expected = '0' 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "index_name,index_label,expected", 2564s [ 2564s # no index name, defaults to 'index' 2564s (None, None, "index"), 2564s # specifying index_label 2564s (None, "other_label", "other_label"), 2564s # using the index name 2564s ("index_name", None, "index_name"), 2564s # has index name, but specifying index_label 2564s ("index_name", "other_label", "other_label"), 2564s # index name is integer 2564s (0, None, "0"), 2564s # index name is None but index label is integer 2564s (None, 0, "0"), 2564s ], 2564s ) 2564s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2564s if "adbc" in conn: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] ______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_index_label_multiindex(conn, request): 2564s conn_name = conn 2564s if "mysql" in conn_name: 2564s request.applymarker( 2564s pytest.mark.xfail( 2564s reason="MySQL can fail using TEXT without length as key", strict=False 2564s ) 2564s ) 2564s elif "adbc" in conn_name: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_index_label", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2004: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _______ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_to_sql_index_label_multiindex(conn, request): 2564s conn_name = conn 2564s if "mysql" in conn_name: 2564s request.applymarker( 2564s pytest.mark.xfail( 2564s reason="MySQL can fail using TEXT without length as key", strict=False 2564s ) 2564s ) 2564s elif "adbc" in conn_name: 2564s request.node.add_marker( 2564s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2564s ) 2564s 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2003: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _____________ test_api_multiindex_roundtrip[mysql_pymysql_engine] ______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_multiindex_roundtrip(conn, request): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_multiindex_roundtrip", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ______________ test_api_multiindex_roundtrip[mysql_pymysql_conn] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_multiindex_roundtrip(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __________ test_api_multiindex_roundtrip[postgresql_psycopg2_engine] ___________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_multiindex_roundtrip(conn, request): 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_multiindex_roundtrip", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ___________ test_api_multiindex_roundtrip[postgresql_psycopg2_conn] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s def test_api_multiindex_roundtrip(conn, request): 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ test_api_dtype_argument[None-mysql_pymysql_engine] ______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s dtype = None 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "dtype", 2564s [ 2564s None, 2564s int, 2564s float, 2564s {"A": int, "B": float}, 2564s ], 2564s ) 2564s def test_api_dtype_argument(conn, request, dtype): 2564s # GH10285 Add dtype argument to read_sql_query 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_dtype_argument", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______________ test_api_dtype_argument[None-mysql_pymysql_conn] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s dtype = None 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "dtype", 2564s [ 2564s None, 2564s int, 2564s float, 2564s {"A": int, "B": float}, 2564s ], 2564s ) 2564s def test_api_dtype_argument(conn, request, dtype): 2564s # GH10285 Add dtype argument to read_sql_query 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_api_dtype_argument[None-postgresql_psycopg2_engine] ___________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s dtype = None 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "dtype", 2564s [ 2564s None, 2564s int, 2564s float, 2564s {"A": int, "B": float}, 2564s ], 2564s ) 2564s def test_api_dtype_argument(conn, request, dtype): 2564s # GH10285 Add dtype argument to read_sql_query 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_dtype_argument", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________ test_api_dtype_argument[None-postgresql_psycopg2_conn] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s dtype = None 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "dtype", 2564s [ 2564s None, 2564s int, 2564s float, 2564s {"A": int, "B": float}, 2564s ], 2564s ) 2564s def test_api_dtype_argument(conn, request, dtype): 2564s # GH10285 Add dtype argument to read_sql_query 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ______________ test_api_dtype_argument[int-mysql_pymysql_engine] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s dtype = 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "dtype", 2564s [ 2564s None, 2564s int, 2564s float, 2564s {"A": int, "B": float}, 2564s ], 2564s ) 2564s def test_api_dtype_argument(conn, request, dtype): 2564s # GH10285 Add dtype argument to read_sql_query 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_dtype_argument", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s _______________ test_api_dtype_argument[int-mysql_pymysql_conn] ________________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s dtype = 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "dtype", 2564s [ 2564s None, 2564s int, 2564s float, 2564s {"A": int, "B": float}, 2564s ], 2564s ) 2564s def test_api_dtype_argument(conn, request, dtype): 2564s # GH10285 Add dtype argument to read_sql_query 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ___________ test_api_dtype_argument[int-postgresql_psycopg2_engine] ____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s dtype = 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "dtype", 2564s [ 2564s None, 2564s int, 2564s float, 2564s {"A": int, "B": float}, 2564s ], 2564s ) 2564s def test_api_dtype_argument(conn, request, dtype): 2564s # GH10285 Add dtype argument to read_sql_query 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_dtype_argument", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s ____________ test_api_dtype_argument[int-postgresql_psycopg2_conn] _____________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'postgresql_psycopg2_conn' 2564s request = > 2564s dtype = 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "dtype", 2564s [ 2564s None, 2564s int, 2564s float, 2564s {"A": int, "B": float}, 2564s ], 2564s ) 2564s def test_api_dtype_argument(conn, request, dtype): 2564s # GH10285 Add dtype argument to read_sql_query 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2564s with postgresql_psycopg2_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s _____________ test_api_dtype_argument[float-mysql_pymysql_engine] ______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2564s request = > 2564s dtype = 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "dtype", 2564s [ 2564s None, 2564s int, 2564s float, 2564s {"A": int, "B": float}, 2564s ], 2564s ) 2564s def test_api_dtype_argument(conn, request, dtype): 2564s # GH10285 Add dtype argument to read_sql_query 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_dtype_argument", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s ______________ test_api_dtype_argument[float-mysql_pymysql_conn] _______________ 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s > sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3.13/socket.py:864: in create_connection 2564s raise exceptions[0] 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s address = ('localhost', 3306), timeout = 10, source_address = None 2564s 2564s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2564s source_address=None, *, all_errors=False): 2564s """Connect to *address* and return the socket object. 2564s 2564s Convenience function. Connect to *address* (a 2-tuple ``(host, 2564s port)``) and return the socket object. Passing the optional 2564s *timeout* parameter will set the timeout on the socket instance 2564s before attempting to connect. If no *timeout* is supplied, the 2564s global default timeout setting returned by :func:`getdefaulttimeout` 2564s is used. If *source_address* is set it must be a tuple of (host, port) 2564s for the socket to bind as a source address before making the connection. 2564s A host of '' or port 0 tells the OS to use the default. When a connection 2564s cannot be created, raises the last error if *all_errors* is False, 2564s and an ExceptionGroup of all errors if *all_errors* is True. 2564s """ 2564s 2564s host, port = address 2564s exceptions = [] 2564s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2564s af, socktype, proto, canonname, sa = res 2564s sock = None 2564s try: 2564s sock = socket(af, socktype, proto) 2564s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2564s sock.settimeout(timeout) 2564s if source_address: 2564s sock.bind(source_address) 2564s > sock.connect(sa) 2564s E ConnectionRefusedError: [Errno 111] Connection refused 2564s 2564s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2564s 2564s During handling of the above exception, another exception occurred: 2564s 2564s self = 2564s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2564s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = 'mysql_pymysql_conn' 2564s request = > 2564s dtype = 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "dtype", 2564s [ 2564s None, 2564s int, 2564s float, 2564s {"A": int, "B": float}, 2564s ], 2564s ) 2564s def test_api_dtype_argument(conn, request, dtype): 2564s # GH10285 Add dtype argument to read_sql_query 2564s conn_name = conn 2564s > conn = request.getfixturevalue(conn) 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2564s fixturedef = self._get_active_fixturedef(argname) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2564s fixturedef.execute(request=subrequest) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2564s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2564s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2564s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2564s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2564s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2564s return (yield) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2564s result = call_fixture_func(fixturefunc, request, kwargs) 2564s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2564s fixture_result = next(generator) 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2564s with mysql_pymysql_engine.connect() as conn: 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2564s self.connect() 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s self = , sock = None 2564s 2564s def connect(self, sock=None): 2564s self._closed = False 2564s try: 2564s if sock is None: 2564s if self.unix_socket: 2564s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2564s sock.settimeout(self.connect_timeout) 2564s sock.connect(self.unix_socket) 2564s self.host_info = "Localhost via UNIX socket" 2564s self._secure = True 2564s if DEBUG: 2564s print("connected using unix_socket") 2564s else: 2564s kwargs = {} 2564s if self.bind_address is not None: 2564s kwargs["source_address"] = (self.bind_address, 0) 2564s while True: 2564s try: 2564s sock = socket.create_connection( 2564s (self.host, self.port), self.connect_timeout, **kwargs 2564s ) 2564s break 2564s except OSError as e: 2564s if e.errno == errno.EINTR: 2564s continue 2564s raise 2564s self.host_info = "socket %s:%d" % (self.host, self.port) 2564s if DEBUG: 2564s print("connected using socket") 2564s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2564s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2564s sock.settimeout(None) 2564s 2564s self._sock = sock 2564s self._rfile = sock.makefile("rb") 2564s self._next_seq_id = 0 2564s 2564s self._get_server_information() 2564s self._request_authentication() 2564s 2564s # Send "SET NAMES" query on init for: 2564s # - Ensure charaset (and collation) is set to the server. 2564s # - collation_id in handshake packet may be ignored. 2564s # - If collation is not specified, we don't know what is server's 2564s # default collation for the charset. For example, default collation 2564s # of utf8mb4 is: 2564s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2564s # - MySQL 8.0: utf8mb4_0900_ai_ci 2564s # 2564s # Reference: 2564s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2564s # - https://github.com/wagtail/wagtail/issues/9477 2564s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2564s self.set_character_set(self.charset, self.collation) 2564s 2564s if self.sql_mode is not None: 2564s c = self.cursor() 2564s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2564s c.close() 2564s 2564s if self.init_command is not None: 2564s c = self.cursor() 2564s c.execute(self.init_command) 2564s c.close() 2564s 2564s if self.autocommit_mode is not None: 2564s self.autocommit(self.autocommit_mode) 2564s except BaseException as e: 2564s self._rfile = None 2564s if sock is not None: 2564s try: 2564s sock.close() 2564s except: # noqa 2564s pass 2564s 2564s if isinstance(e, (OSError, IOError)): 2564s exc = err.OperationalError( 2564s CR.CR_CONN_HOST_ERROR, 2564s f"Can't connect to MySQL server on {self.host!r} ({e})", 2564s ) 2564s # Keep original exception and traceback to investigate error. 2564s exc.original_exception = e 2564s exc.traceback = traceback.format_exc() 2564s if DEBUG: 2564s print(exc.traceback) 2564s > raise exc 2564s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2564s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2564s 2564s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2564s __________ test_api_dtype_argument[float-postgresql_psycopg2_engine] ___________ 2564s self = 2564s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s connection = None, _has_events = None, _allow_revalidate = True 2564s _allow_autobegin = True 2564s 2564s def __init__( 2564s self, 2564s engine: Engine, 2564s connection: Optional[PoolProxiedConnection] = None, 2564s _has_events: Optional[bool] = None, 2564s _allow_revalidate: bool = True, 2564s _allow_autobegin: bool = True, 2564s ): 2564s """Construct a new Connection.""" 2564s self.engine = engine 2564s self.dialect = dialect = engine.dialect 2564s 2564s if connection is None: 2564s try: 2564s > self._dbapi_connection = engine.raw_connection() 2564s 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2564s - *host*: database host address (defaults to UNIX socket if not provided) 2564s - *port*: connection port number (defaults to 5432 if not provided) 2564s 2564s Using the *connection_factory* parameter a different class or connections 2564s factory can be specified. It should be a callable object taking a dsn 2564s argument. 2564s 2564s Using the *cursor_factory* parameter, a new default cursor factory will be 2564s used by cursor(). 2564s 2564s Using *async*=True an asynchronous connection will be created. *async_* is 2564s a valid alias (for Python versions where ``async`` is a keyword). 2564s 2564s Any other keyword parameter will be passed to the underlying client 2564s library: the list of supported parameters depends on the library version. 2564s 2564s """ 2564s kwasync = {} 2564s if 'async' in kwargs: 2564s kwasync['async'] = kwargs.pop('async') 2564s if 'async_' in kwargs: 2564s kwasync['async_'] = kwargs.pop('async_') 2564s 2564s dsn = _ext.make_dsn(dsn, **kwargs) 2564s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2564s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2564s E Is the server running on that host and accepting TCP/IP connections? 2564s 2564s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2564s 2564s The above exception was the direct cause of the following exception: 2564s 2564s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2564s request = > 2564s dtype = 2564s 2564s @pytest.mark.parametrize("conn", all_connectable) 2564s @pytest.mark.parametrize( 2564s "dtype", 2564s [ 2564s None, 2564s int, 2564s float, 2564s {"A": int, "B": float}, 2564s ], 2564s ) 2564s def test_api_dtype_argument(conn, request, dtype): 2564s # GH10285 Add dtype argument to read_sql_query 2564s conn_name = conn 2564s conn = request.getfixturevalue(conn) 2564s > if sql.has_table("test_dtype_argument", conn): 2564s 2564s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2564s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2564s return SQLDatabase(con, schema, need_transaction) 2564s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2564s con = self.exit_stack.enter_context(con.connect()) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2564s return self._connection_cls(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2564s Connection._handle_dbapi_exception_noconnection( 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2564s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2564s self._dbapi_connection = engine.raw_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2564s return self.pool.connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2564s return _ConnectionFairy._checkout(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2564s fairy = _ConnectionRecord.checkout(pool) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2564s rec = pool._do_get() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2564s return self._create_connection() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2564s return _ConnectionRecord(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2564s self.__connect() 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2564s with util.safe_reraise(): 2564s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2564s raise exc_value.with_traceback(exc_tb) 2564s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2564s self.dbapi_connection = connection = pool._invoke_creator(self) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2564s return dialect.connect(*cargs, **cparams) 2564s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2564s return self.loaded_dbapi.connect(*cargs, **cparams) 2564s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2564s 2564s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2564s connection_factory = None, cursor_factory = None 2564s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2564s kwasync = {} 2564s 2564s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2564s """ 2564s Create a new database connection. 2564s 2564s The connection parameters can be specified as a string: 2564s 2564s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2564s 2564s or using a set of keyword arguments: 2564s 2564s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2564s 2564s Or as a mix of both. The basic connection parameters are: 2564s 2564s - *dbname*: the database name 2564s - *database*: the database name (only as keyword argument) 2564s - *user*: user name used to authenticate 2564s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________ test_api_dtype_argument[float-postgresql_psycopg2_conn] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s dtype = 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize( 2565s "dtype", 2565s [ 2565s None, 2565s int, 2565s float, 2565s {"A": int, "B": float}, 2565s ], 2565s ) 2565s def test_api_dtype_argument(conn, request, dtype): 2565s # GH10285 Add dtype argument to read_sql_query 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____________ test_api_dtype_argument[dtype3-mysql_pymysql_engine] _____________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s dtype = {'A': , 'B': } 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize( 2565s "dtype", 2565s [ 2565s None, 2565s int, 2565s float, 2565s {"A": int, "B": float}, 2565s ], 2565s ) 2565s def test_api_dtype_argument(conn, request, dtype): 2565s # GH10285 Add dtype argument to read_sql_query 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("test_dtype_argument", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______________ test_api_dtype_argument[dtype3-mysql_pymysql_conn] ______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s dtype = {'A': , 'B': } 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize( 2565s "dtype", 2565s [ 2565s None, 2565s int, 2565s float, 2565s {"A": int, "B": float}, 2565s ], 2565s ) 2565s def test_api_dtype_argument(conn, request, dtype): 2565s # GH10285 Add dtype argument to read_sql_query 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________ test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] __________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s dtype = {'A': , 'B': } 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize( 2565s "dtype", 2565s [ 2565s None, 2565s int, 2565s float, 2565s {"A": int, "B": float}, 2565s ], 2565s ) 2565s def test_api_dtype_argument(conn, request, dtype): 2565s # GH10285 Add dtype argument to read_sql_query 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("test_dtype_argument", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________ test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] ___________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s dtype = {'A': , 'B': } 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize( 2565s "dtype", 2565s [ 2565s None, 2565s int, 2565s float, 2565s {"A": int, "B": float}, 2565s ], 2565s ) 2565s def test_api_dtype_argument(conn, request, dtype): 2565s # GH10285 Add dtype argument to read_sql_query 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______________ test_api_integer_col_names[mysql_pymysql_engine] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_integer_col_names(conn, request): 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 2565s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________________ test_api_integer_col_names[mysql_pymysql_conn] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_integer_col_names(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________ test_api_integer_col_names[postgresql_psycopg2_engine] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_integer_col_names(conn, request): 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 2565s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____________ test_api_integer_col_names[postgresql_psycopg2_conn] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_integer_col_names(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________________ test_api_get_schema[mysql_pymysql_engine] ___________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema(conn, request, test_frame1): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn = request.getfixturevalue(conn) 2565s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2565s with pandasSQL_builder(con=con) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________________ test_api_get_schema[mysql_pymysql_conn] ____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema(conn, request, test_frame1): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_api_get_schema[postgresql_psycopg2_engine] ________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema(conn, request, test_frame1): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn = request.getfixturevalue(conn) 2565s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2565s with pandasSQL_builder(con=con) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________________ test_api_get_schema[postgresql_psycopg2_conn] _________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema(conn, request, test_frame1): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_api_get_schema_with_schema[mysql_pymysql_engine] _____________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_with_schema(conn, request, test_frame1): 2565s # GH28486 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn = request.getfixturevalue(conn) 2565s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2565s with pandasSQL_builder(con=con) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________ test_api_get_schema_with_schema[mysql_pymysql_conn] ______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_with_schema(conn, request, test_frame1): 2565s # GH28486 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________ test_api_get_schema_with_schema[postgresql_psycopg2_engine] __________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_with_schema(conn, request, test_frame1): 2565s # GH28486 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn = request.getfixturevalue(conn) 2565s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2565s with pandasSQL_builder(con=con) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________ test_api_get_schema_with_schema[postgresql_psycopg2_conn] ___________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_with_schema(conn, request, test_frame1): 2565s # GH28486 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______________ test_api_get_schema_dtypes[mysql_pymysql_engine] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_dtypes(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 2565s 2565s if conn_name == "sqlite_buildin": 2565s dtype = "INTEGER" 2565s else: 2565s from sqlalchemy import Integer 2565s 2565s dtype = Integer 2565s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2565s with pandasSQL_builder(con=con) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________________ test_api_get_schema_dtypes[mysql_pymysql_conn] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_dtypes(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________ test_api_get_schema_dtypes[postgresql_psycopg2_engine] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_dtypes(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 2565s 2565s if conn_name == "sqlite_buildin": 2565s dtype = "INTEGER" 2565s else: 2565s from sqlalchemy import Integer 2565s 2565s dtype = Integer 2565s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2565s with pandasSQL_builder(con=con) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____________ test_api_get_schema_dtypes[postgresql_psycopg2_conn] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_dtypes(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________________ test_api_get_schema_keys[mysql_pymysql_engine] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_keys(conn, request, test_frame1): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 2565s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2565s with pandasSQL_builder(con=con) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________________ test_api_get_schema_keys[mysql_pymysql_conn] _________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_keys(conn, request, test_frame1): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________ test_api_get_schema_keys[postgresql_psycopg2_engine] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_keys(conn, request, test_frame1): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 2565s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2565s with pandasSQL_builder(con=con) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_api_get_schema_keys[postgresql_psycopg2_conn] ______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_get_schema_keys(conn, request, test_frame1): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="'get_schema' not implemented for ADBC drivers", 2565s strict=True, 2565s ) 2565s ) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________________ test_api_chunksize_read[mysql_pymysql_engine] _________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_chunksize_read(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2565s ) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("test_chunksize", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________________ test_api_chunksize_read[mysql_pymysql_conn] __________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_chunksize_read(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2565s ) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________ test_api_chunksize_read[postgresql_psycopg2_engine] ______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_chunksize_read(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2565s ) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("test_chunksize", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_api_chunksize_read[postgresql_psycopg2_conn] _______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_chunksize_read(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2565s ) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________________ test_api_categorical[mysql_pymysql_engine] __________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_categorical(conn, request): 2565s if conn == "postgresql_adbc_conn": 2565s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2565s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="categorical dtype not implemented for ADBC postgres driver", 2565s strict=True, 2565s ) 2565s ) 2565s # GH8624 2565s # test that categorical gets written correctly as dense column 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("test_categorical", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________________ test_api_categorical[mysql_pymysql_conn] ___________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_categorical(conn, request): 2565s if conn == "postgresql_adbc_conn": 2565s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2565s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="categorical dtype not implemented for ADBC postgres driver", 2565s strict=True, 2565s ) 2565s ) 2565s # GH8624 2565s # test that categorical gets written correctly as dense column 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_api_categorical[postgresql_psycopg2_engine] _______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_categorical(conn, request): 2565s if conn == "postgresql_adbc_conn": 2565s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2565s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="categorical dtype not implemented for ADBC postgres driver", 2565s strict=True, 2565s ) 2565s ) 2565s # GH8624 2565s # test that categorical gets written correctly as dense column 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("test_categorical", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________________ test_api_categorical[postgresql_psycopg2_conn] ________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_categorical(conn, request): 2565s if conn == "postgresql_adbc_conn": 2565s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2565s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="categorical dtype not implemented for ADBC postgres driver", 2565s strict=True, 2565s ) 2565s ) 2565s # GH8624 2565s # test that categorical gets written correctly as dense column 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_api_unicode_column_name[mysql_pymysql_engine] ______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_unicode_column_name(conn, request): 2565s # GH 11431 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("test_unicode", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_api_unicode_column_name[mysql_pymysql_conn] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_unicode_column_name(conn, request): 2565s # GH 11431 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_api_unicode_column_name[postgresql_psycopg2_engine] ___________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_unicode_column_name(conn, request): 2565s # GH 11431 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("test_unicode", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_api_unicode_column_name[postgresql_psycopg2_conn] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_unicode_column_name(conn, request): 2565s # GH 11431 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_api_escaped_table_name[mysql_pymysql_engine] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_escaped_table_name(conn, request): 2565s # GH 13206 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_api_escaped_table_name[mysql_pymysql_conn] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_escaped_table_name(conn, request): 2565s # GH 13206 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_api_escaped_table_name[postgresql_psycopg2_engine] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_escaped_table_name(conn, request): 2565s # GH 13206 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_api_escaped_table_name[postgresql_psycopg2_conn] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_escaped_table_name(conn, request): 2565s # GH 13206 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________ test_api_read_sql_duplicate_columns[mysql_pymysql_engine] ___________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_read_sql_duplicate_columns(conn, request): 2565s # GH#53117 2565s if "adbc" in conn: 2565s pa = pytest.importorskip("pyarrow") 2565s if not ( 2565s Version(pa.__version__) >= Version("16.0") 2565s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2565s ): 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="pyarrow->pandas throws ValueError", strict=True 2565s ) 2565s ) 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("test_table", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_api_read_sql_duplicate_columns[mysql_pymysql_conn] ____________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_read_sql_duplicate_columns(conn, request): 2565s # GH#53117 2565s if "adbc" in conn: 2565s pa = pytest.importorskip("pyarrow") 2565s if not ( 2565s Version(pa.__version__) >= Version("16.0") 2565s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2565s ): 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="pyarrow->pandas throws ValueError", strict=True 2565s ) 2565s ) 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______ test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] ________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_read_sql_duplicate_columns(conn, request): 2565s # GH#53117 2565s if "adbc" in conn: 2565s pa = pytest.importorskip("pyarrow") 2565s if not ( 2565s Version(pa.__version__) >= Version("16.0") 2565s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2565s ): 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="pyarrow->pandas throws ValueError", strict=True 2565s ) 2565s ) 2565s conn = request.getfixturevalue(conn) 2565s > if sql.has_table("test_table", conn): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2565s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________ test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_api_read_sql_duplicate_columns(conn, request): 2565s # GH#53117 2565s if "adbc" in conn: 2565s pa = pytest.importorskip("pyarrow") 2565s if not ( 2565s Version(pa.__version__) >= Version("16.0") 2565s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2565s ): 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="pyarrow->pandas throws ValueError", strict=True 2565s ) 2565s ) 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________________ test_read_table_columns[mysql_pymysql_engine] _________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_read_table_columns(conn, request, test_frame1): 2565s # test columns argument in read_table 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s conn = request.getfixturevalue(conn) 2565s > sql.to_sql(test_frame1, "test_frame", conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________________ test_read_table_columns[mysql_pymysql_conn] __________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_read_table_columns(conn, request, test_frame1): 2565s # test columns argument in read_table 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________ test_read_table_columns[postgresql_psycopg2_engine] ______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_read_table_columns(conn, request, test_frame1): 2565s # test columns argument in read_table 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s conn = request.getfixturevalue(conn) 2565s > sql.to_sql(test_frame1, "test_frame", conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_read_table_columns[postgresql_psycopg2_conn] _______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_read_table_columns(conn, request, test_frame1): 2565s # test columns argument in read_table 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______________ test_read_table_index_col[mysql_pymysql_engine] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_read_table_index_col(conn, request, test_frame1): 2565s # test columns argument in read_table 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s conn = request.getfixturevalue(conn) 2565s > sql.to_sql(test_frame1, "test_frame", conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________________ test_read_table_index_col[mysql_pymysql_conn] _________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_read_table_index_col(conn, request, test_frame1): 2565s # test columns argument in read_table 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________ test_read_table_index_col[postgresql_psycopg2_engine] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_read_table_index_col(conn, request, test_frame1): 2565s # test columns argument in read_table 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s conn = request.getfixturevalue(conn) 2565s > sql.to_sql(test_frame1, "test_frame", conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____________ test_read_table_index_col[postgresql_psycopg2_conn] ______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_read_table_index_col(conn, request, test_frame1): 2565s # test columns argument in read_table 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_read_sql_delegate[mysql_pymysql_engine_iris] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable_iris) 2565s def test_read_sql_delegate(conn, request): 2565s if conn == "sqlite_buildin_iris": 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason="sqlite_buildin connection does not implement read_sql_table" 2565s ) 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_read_sql_delegate[mysql_pymysql_conn_iris] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable_iris) 2565s def test_read_sql_delegate(conn, request): 2565s if conn == "sqlite_buildin_iris": 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason="sqlite_buildin connection does not implement read_sql_table" 2565s ) 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_read_sql_delegate[postgresql_psycopg2_engine_iris] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable_iris) 2565s def test_read_sql_delegate(conn, request): 2565s if conn == "sqlite_buildin_iris": 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason="sqlite_buildin connection does not implement read_sql_table" 2565s ) 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_read_sql_delegate[postgresql_psycopg2_conn_iris] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable_iris) 2565s def test_read_sql_delegate(conn, request): 2565s if conn == "sqlite_buildin_iris": 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason="sqlite_buildin connection does not implement read_sql_table" 2565s ) 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________ test_warning_case_insensitive_table_name[mysql_pymysql_engine] ________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2565s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2565s 2565s conn = request.getfixturevalue(conn) 2565s # see gh-7815 2565s with tm.assert_produces_warning( 2565s UserWarning, 2565s match=( 2565s r"The provided table name 'TABLE1' is not found exactly as such in " 2565s r"the database after writing the table, possibly due to case " 2565s r"sensitivity issues. Consider using lower case table names." 2565s ), 2565s ): 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2565s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2565s 2565s conn = request.getfixturevalue(conn) 2565s # see gh-7815 2565s > with tm.assert_produces_warning( 2565s UserWarning, 2565s match=( 2565s r"The provided table name 'TABLE1' is not found exactly as such in " 2565s r"the database after writing the table, possibly due to case " 2565s r"sensitivity issues. Consider using lower case table names." 2565s ), 2565s ): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/contextlib.py:162: in __exit__ 2565s self.gen.throw(value) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s def _assert_caught_expected_warning( 2565s *, 2565s caught_warnings: Sequence[warnings.WarningMessage], 2565s expected_warning: type[Warning], 2565s match: str | None, 2565s check_stacklevel: bool, 2565s ) -> None: 2565s """Assert that there was the expected warning among the caught warnings.""" 2565s saw_warning = False 2565s matched_message = False 2565s unmatched_messages = [] 2565s 2565s for actual_warning in caught_warnings: 2565s if issubclass(actual_warning.category, expected_warning): 2565s saw_warning = True 2565s 2565s if check_stacklevel: 2565s _assert_raised_with_correct_stacklevel(actual_warning) 2565s 2565s if match is not None: 2565s if re.search(match, str(actual_warning.message)): 2565s matched_message = True 2565s else: 2565s unmatched_messages.append(actual_warning.message) 2565s 2565s if not saw_warning: 2565s > raise AssertionError( 2565s f"Did not see expected warning of class " 2565s f"{repr(expected_warning.__name__)}" 2565s ) 2565s E AssertionError: Did not see expected warning of class 'UserWarning' 2565s 2565s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 2565s _________ test_warning_case_insensitive_table_name[mysql_pymysql_conn] _________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2565s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____ test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2565s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2565s 2565s conn = request.getfixturevalue(conn) 2565s # see gh-7815 2565s with tm.assert_produces_warning( 2565s UserWarning, 2565s match=( 2565s r"The provided table name 'TABLE1' is not found exactly as such in " 2565s r"the database after writing the table, possibly due to case " 2565s r"sensitivity issues. Consider using lower case table names." 2565s ), 2565s ): 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2565s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2565s 2565s conn = request.getfixturevalue(conn) 2565s # see gh-7815 2565s > with tm.assert_produces_warning( 2565s UserWarning, 2565s match=( 2565s r"The provided table name 'TABLE1' is not found exactly as such in " 2565s r"the database after writing the table, possibly due to case " 2565s r"sensitivity issues. Consider using lower case table names." 2565s ), 2565s ): 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/contextlib.py:162: in __exit__ 2565s self.gen.throw(value) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s def _assert_caught_expected_warning( 2565s *, 2565s caught_warnings: Sequence[warnings.WarningMessage], 2565s expected_warning: type[Warning], 2565s match: str | None, 2565s check_stacklevel: bool, 2565s ) -> None: 2565s """Assert that there was the expected warning among the caught warnings.""" 2565s saw_warning = False 2565s matched_message = False 2565s unmatched_messages = [] 2565s 2565s for actual_warning in caught_warnings: 2565s if issubclass(actual_warning.category, expected_warning): 2565s saw_warning = True 2565s 2565s if check_stacklevel: 2565s _assert_raised_with_correct_stacklevel(actual_warning) 2565s 2565s if match is not None: 2565s if re.search(match, str(actual_warning.message)): 2565s matched_message = True 2565s else: 2565s unmatched_messages.append(actual_warning.message) 2565s 2565s if not saw_warning: 2565s > raise AssertionError( 2565s f"Did not see expected warning of class " 2565s f"{repr(expected_warning.__name__)}" 2565s ) 2565s E AssertionError: Did not see expected warning of class 'UserWarning' 2565s 2565s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 2565s ______ test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] ______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2565s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_sqlalchemy_type_mapping[mysql_pymysql_engine] ______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_sqlalchemy_type_mapping(conn, request): 2565s conn = request.getfixturevalue(conn) 2565s from sqlalchemy import TIMESTAMP 2565s 2565s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 2565s df = DataFrame( 2565s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 2565s ) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_sqlalchemy_type_mapping[mysql_pymysql_conn] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_sqlalchemy_type_mapping(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] ___________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_sqlalchemy_type_mapping(conn, request): 2565s conn = request.getfixturevalue(conn) 2565s from sqlalchemy import TIMESTAMP 2565s 2565s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 2565s df = DataFrame( 2565s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 2565s ) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_sqlalchemy_type_mapping(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'int8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'int8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'int8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'int8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'Int8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'Int8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'Int8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'Int8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'uint8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'uint8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] __ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'uint8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'uint8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'UInt8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'UInt8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] __ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'UInt8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'UInt8', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'int16', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'int16', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] __ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'int16', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'int16', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'Int16', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'Int16', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] __ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'Int16', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'Int16', expected = 'SMALLINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'uint16', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'uint16', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] __ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'uint16', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'uint16', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'UInt16', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'UInt16', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] __ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'UInt16', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'UInt16', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'int32', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'int32', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'int32', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'int32', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'Int32', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'Int32', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'Int32', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'Int32', expected = 'INTEGER' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'uint32', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'uint32', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'uint32', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'uint32', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'UInt32', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'UInt32', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'UInt32', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'UInt32', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'int64', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'int64', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'int64', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'int64', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'Int64', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'Int64', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'Int64', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'Int64', expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = , expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] ________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = , expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = , expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = , expected = 'BIGINT' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "integer, expected", 2565s [ 2565s ("int8", "SMALLINT"), 2565s ("Int8", "SMALLINT"), 2565s ("uint8", "SMALLINT"), 2565s ("UInt8", "SMALLINT"), 2565s ("int16", "SMALLINT"), 2565s ("Int16", "SMALLINT"), 2565s ("uint16", "INTEGER"), 2565s ("UInt16", "INTEGER"), 2565s ("int32", "INTEGER"), 2565s ("Int32", "INTEGER"), 2565s ("uint32", "BIGINT"), 2565s ("UInt32", "BIGINT"), 2565s ("int64", "BIGINT"), 2565s ("Int64", "BIGINT"), 2565s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2565s ], 2565s ) 2565s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'uint64' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2565s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2565s conn = request.getfixturevalue(conn) 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'uint64' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2565s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] __ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'uint64' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2565s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2565s conn = request.getfixturevalue(conn) 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'uint64' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2565s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s integer = 'UInt64' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2565s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2565s conn = request.getfixturevalue(conn) 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] ______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s integer = 'UInt64' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2565s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] __ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s integer = 'UInt64' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2565s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2565s conn = request.getfixturevalue(conn) 2565s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2565s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2565s > with sql.SQLDatabase(conn) as db: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s integer = 'UInt64' 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2565s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________ test_database_uri_string[mysql_pymysql_conn] _________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_database_uri_string(conn, request, test_frame1): 2565s td.versioned_importorskip("sqlalchemy") 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______________ test_database_uri_string[postgresql_psycopg2_conn] ______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_database_uri_string(conn, request, test_frame1): 2565s td.versioned_importorskip("sqlalchemy") 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________ test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @td.skip_if_installed("pg8000") 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 2565s td.versioned_importorskip("sqlalchemy") 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] ______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @td.skip_if_installed("pg8000") 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 2565s td.versioned_importorskip("sqlalchemy") 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_query_by_text_obj[mysql_pymysql_engine_iris] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_query_by_text_obj(conn, request): 2565s # WIP : GH10846 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_query_by_text_obj[mysql_pymysql_conn_iris] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_query_by_text_obj(conn, request): 2565s # WIP : GH10846 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_query_by_text_obj[postgresql_psycopg2_engine_iris] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_query_by_text_obj(conn, request): 2565s # WIP : GH10846 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_query_by_text_obj[postgresql_psycopg2_conn_iris] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_query_by_text_obj(conn, request): 2565s # WIP : GH10846 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____________ test_query_by_select_obj[mysql_pymysql_engine_iris] ______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_query_by_select_obj(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______________ test_query_by_select_obj[mysql_pymysql_conn_iris] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_query_by_select_obj(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________ test_query_by_select_obj[postgresql_psycopg2_engine_iris] ___________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_query_by_select_obj(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________ test_query_by_select_obj[postgresql_psycopg2_conn_iris] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_query_by_select_obj(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_column_with_percentage[mysql_pymysql_engine] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_column_with_percentage(conn, request): 2565s # GH 37157 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 2565s > df.to_sql(name="test_column_percentage", con=conn, index=False) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_column_with_percentage[mysql_pymysql_conn] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_column_with_percentage(conn, request): 2565s # GH 37157 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_column_with_percentage[postgresql_psycopg2_engine] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_column_with_percentage(conn, request): 2565s # GH 37157 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 2565s > df.to_sql(name="test_column_percentage", con=conn, index=False) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_column_with_percentage[postgresql_psycopg2_conn] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_column_with_percentage(conn, request): 2565s # GH 37157 2565s conn_name = conn 2565s if conn_name == "sqlite_buildin": 2565s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________________ test_create_table[mysql_pymysql_engine] ____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_create_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import inspect 2565s 2565s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2565s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________________ test_create_table[mysql_pymysql_conn] _____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_create_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________________ test_create_table[postgresql_psycopg2_engine] _________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_create_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import inspect 2565s 2565s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2565s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________ test_create_table[postgresql_psycopg2_conn] __________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_create_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________________ test_drop_table[mysql_pymysql_engine] _____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_drop_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import inspect 2565s 2565s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2565s > with sql.SQLDatabase(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________________ test_drop_table[mysql_pymysql_conn] ______________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_drop_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________________ test_drop_table[postgresql_psycopg2_engine] __________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_drop_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import inspect 2565s 2565s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2565s > with sql.SQLDatabase(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________________ test_drop_table[postgresql_psycopg2_conn] ___________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_drop_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____________________ test_roundtrip[mysql_pymysql_engine] _____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_roundtrip(conn, request, test_frame1): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s > pandasSQL = pandasSQL_builder(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______________________ test_roundtrip[mysql_pymysql_conn] ______________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_roundtrip(conn, request, test_frame1): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________________ test_roundtrip[postgresql_psycopg2_engine] __________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_roundtrip(conn, request, test_frame1): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s > pandasSQL = pandasSQL_builder(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________________ test_roundtrip[postgresql_psycopg2_conn] ___________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_roundtrip(conn, request, test_frame1): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________ test_execute_sql[mysql_pymysql_engine_iris] __________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable_iris) 2565s def test_execute_sql(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________________ test_execute_sql[mysql_pymysql_conn_iris] ___________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable_iris) 2565s def test_execute_sql(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______________ test_execute_sql[postgresql_psycopg2_engine_iris] _______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable_iris) 2565s def test_execute_sql(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______________ test_execute_sql[postgresql_psycopg2_conn_iris] ________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable_iris) 2565s def test_execute_sql(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_sqlalchemy_read_table[mysql_pymysql_engine_iris] _____________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_sqlalchemy_read_table(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________ test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_sqlalchemy_read_table(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________ test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] __________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_sqlalchemy_read_table(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________ test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] ___________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_sqlalchemy_read_table(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________ test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_sqlalchemy_read_table_columns(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________ test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] __________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_sqlalchemy_read_table_columns(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____ test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] ______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_sqlalchemy_read_table_columns(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______ test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_sqlalchemy_read_table_columns(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________ test_read_table_absent_raises[mysql_pymysql_engine_iris] ___________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_read_table_absent_raises(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________ test_read_table_absent_raises[mysql_pymysql_conn_iris] ____________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_read_table_absent_raises(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2565s create_and_load_iris(mysql_pymysql_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________ test_read_table_absent_raises[postgresql_psycopg2_engine_iris] ________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_engine_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_read_table_absent_raises(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________ test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn_iris' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2565s def test_read_table_absent_raises(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2565s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2565s with conn.begin() as con: 2565s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2565s return next(self.gen) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2565s with self.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_engine_types' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2565s def test_sqlalchemy_default_type_conversion(conn, request): 2565s conn_name = conn 2565s if conn_name == "sqlite_str": 2565s pytest.skip("types tables not created in sqlite_str fixture") 2565s elif "mysql" in conn_name or "sqlite" in conn_name: 2565s request.applymarker( 2565s pytest.mark.xfail(reason="boolean dtype not inferred properly") 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2565s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn_types' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2565s def test_sqlalchemy_default_type_conversion(conn, request): 2565s conn_name = conn 2565s if conn_name == "sqlite_str": 2565s pytest.skip("types tables not created in sqlite_str fixture") 2565s elif "mysql" in conn_name or "sqlite" in conn_name: 2565s request.applymarker( 2565s pytest.mark.xfail(reason="boolean dtype not inferred properly") 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2565s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________________ test_bigint[mysql_pymysql_engine] _______________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_bigint(conn, request): 2565s # int64 should be converted to BigInteger, GH7433 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame(data={"i64": [2**62]}) 2565s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________________ test_bigint[mysql_pymysql_conn] ________________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_bigint(conn, request): 2565s # int64 should be converted to BigInteger, GH7433 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________________ test_bigint[postgresql_psycopg2_engine] ____________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_bigint(conn, request): 2565s # int64 should be converted to BigInteger, GH7433 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame(data={"i64": [2**62]}) 2565s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________________ test_bigint[postgresql_psycopg2_conn] _____________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_bigint(conn, request): 2565s # int64 should be converted to BigInteger, GH7433 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_default_date_load[mysql_pymysql_engine_types] ______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_engine_types' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2565s def test_default_date_load(conn, request): 2565s conn_name = conn 2565s if conn_name == "sqlite_str": 2565s pytest.skip("types tables not created in sqlite_str fixture") 2565s elif "sqlite" in conn_name: 2565s request.applymarker( 2565s pytest.mark.xfail(reason="sqlite does not read date properly") 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2565s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_default_date_load[mysql_pymysql_conn_types] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn_types' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2565s def test_default_date_load(conn, request): 2565s conn_name = conn 2565s if conn_name == "sqlite_str": 2565s pytest.skip("types tables not created in sqlite_str fixture") 2565s elif "sqlite" in conn_name: 2565s request.applymarker( 2565s pytest.mark.xfail(reason="sqlite does not read date properly") 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2565s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_default_date_load[postgresql_psycopg2_engine_types] ___________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_engine_types' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2565s def test_default_date_load(conn, request): 2565s conn_name = conn 2565s if conn_name == "sqlite_str": 2565s pytest.skip("types tables not created in sqlite_str fixture") 2565s elif "sqlite" in conn_name: 2565s request.applymarker( 2565s pytest.mark.xfail(reason="sqlite does not read date properly") 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2565s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_default_date_load[postgresql_psycopg2_conn_types] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn_types' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2565s def test_default_date_load(conn, request): 2565s conn_name = conn 2565s if conn_name == "sqlite_str": 2565s pytest.skip("types tables not created in sqlite_str fixture") 2565s elif "sqlite" in conn_name: 2565s request.applymarker( 2565s pytest.mark.xfail(reason="sqlite does not read date properly") 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2565s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______ test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] ______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s parse_dates = None 2565s 2565s @pytest.mark.parametrize("conn", postgresql_connectable) 2565s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2565s def test_datetime_with_timezone_query(conn, request, parse_dates): 2565s # edge case that converts postgresql datetime with time zone types 2565s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2565s # but should be more natural, so coerce to datetime64[ns] for now 2565s conn = request.getfixturevalue(conn) 2565s > expected = create_and_load_postgres_datetz(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______ test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s parse_dates = None 2565s 2565s @pytest.mark.parametrize("conn", postgresql_connectable) 2565s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2565s def test_datetime_with_timezone_query(conn, request, parse_dates): 2565s # edge case that converts postgresql datetime with time zone types 2565s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2565s # but should be more natural, so coerce to datetime64[ns] for now 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] __ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s parse_dates = ['DateColWithTz'] 2565s 2565s @pytest.mark.parametrize("conn", postgresql_connectable) 2565s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2565s def test_datetime_with_timezone_query(conn, request, parse_dates): 2565s # edge case that converts postgresql datetime with time zone types 2565s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2565s # but should be more natural, so coerce to datetime64[ns] for now 2565s conn = request.getfixturevalue(conn) 2565s > expected = create_and_load_postgres_datetz(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] ___ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s parse_dates = ['DateColWithTz'] 2565s 2565s @pytest.mark.parametrize("conn", postgresql_connectable) 2565s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2565s def test_datetime_with_timezone_query(conn, request, parse_dates): 2565s # edge case that converts postgresql datetime with time zone types 2565s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2565s # but should be more natural, so coerce to datetime64[ns] for now 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", postgresql_connectable) 2565s def test_datetime_with_timezone_query_chunksize(conn, request): 2565s conn = request.getfixturevalue(conn) 2565s > expected = create_and_load_postgres_datetz(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2843: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", postgresql_connectable) 2565s def test_datetime_with_timezone_query_chunksize(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2842: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________ test_datetime_with_timezone_table[postgresql_psycopg2_engine] _________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", postgresql_connectable) 2565s def test_datetime_with_timezone_table(conn, request): 2565s conn = request.getfixturevalue(conn) 2565s > expected = create_and_load_postgres_datetz(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2856: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________ test_datetime_with_timezone_table[postgresql_psycopg2_conn] __________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", postgresql_connectable) 2565s def test_datetime_with_timezone_table(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2855: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________ test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] __________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_with_timezone_roundtrip(conn, request): 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s # GH 9086 2565s # Write datetimetz data to a db and read it back 2565s # For dbs that support timestamps with timezones, should get back UTC 2565s # otherwise naive data should be returned 2565s expected = DataFrame( 2565s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 2565s ) 2565s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________ test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] ___________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_with_timezone_roundtrip(conn, request): 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_with_timezone_roundtrip(conn, request): 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s # GH 9086 2565s # Write datetimetz data to a db and read it back 2565s # For dbs that support timestamps with timezones, should get back UTC 2565s # otherwise naive data should be returned 2565s expected = DataFrame( 2565s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 2565s ) 2565s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] ________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_with_timezone_roundtrip(conn, request): 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_out_of_bounds_datetime[mysql_pymysql_engine] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_out_of_bounds_datetime(conn, request): 2565s # GH 26761 2565s conn = request.getfixturevalue(conn) 2565s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 2565s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_out_of_bounds_datetime[mysql_pymysql_conn] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_out_of_bounds_datetime(conn, request): 2565s # GH 26761 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_out_of_bounds_datetime[postgresql_psycopg2_engine] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_out_of_bounds_datetime(conn, request): 2565s # GH 26761 2565s conn = request.getfixturevalue(conn) 2565s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 2565s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_out_of_bounds_datetime[postgresql_psycopg2_conn] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_out_of_bounds_datetime(conn, request): 2565s # GH 26761 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________ test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] ___________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_naive_datetimeindex_roundtrip(conn, request): 2565s # GH 23510 2565s # Ensure that a naive DatetimeIndex isn't converted to UTC 2565s conn = request.getfixturevalue(conn) 2565s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 2565s expected = DataFrame({"nums": range(5)}, index=dates) 2565s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________ test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] ____________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_naive_datetimeindex_roundtrip(conn, request): 2565s # GH 23510 2565s # Ensure that a naive DatetimeIndex isn't converted to UTC 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] ________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_naive_datetimeindex_roundtrip(conn, request): 2565s # GH 23510 2565s # Ensure that a naive DatetimeIndex isn't converted to UTC 2565s conn = request.getfixturevalue(conn) 2565s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 2565s expected = DataFrame({"nums": range(5)}, index=dates) 2565s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_naive_datetimeindex_roundtrip(conn, request): 2565s # GH 23510 2565s # Ensure that a naive DatetimeIndex isn't converted to UTC 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________________ test_date_parsing[mysql_pymysql_engine_types] _________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_engine_types' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2565s def test_date_parsing(conn, request): 2565s # No Parsing 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2565s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________________ test_date_parsing[mysql_pymysql_conn_types] __________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn_types' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2565s def test_date_parsing(conn, request): 2565s # No Parsing 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2565s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________ test_date_parsing[postgresql_psycopg2_engine_types] ______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_engine_types' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2565s def test_date_parsing(conn, request): 2565s # No Parsing 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2565s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_date_parsing[postgresql_psycopg2_conn_types] _______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn_types' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2565s def test_date_parsing(conn, request): 2565s # No Parsing 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2565s fixturedef = request._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2565s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2565s with conn.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____________________ test_datetime[mysql_pymysql_engine] ______________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime(conn, request): 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame( 2565s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2565s ) 2565s > assert df.to_sql(name="test_datetime", con=conn) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______________________ test_datetime[mysql_pymysql_conn] _______________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime(conn, request): 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________________ test_datetime[postgresql_psycopg2_engine] ___________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime(conn, request): 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame( 2565s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2565s ) 2565s > assert df.to_sql(name="test_datetime", con=conn) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________________ test_datetime[postgresql_psycopg2_conn] ____________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime(conn, request): 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________________ test_datetime_NaT[mysql_pymysql_engine] ____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_NaT(conn, request): 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame( 2565s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2565s ) 2565s df.loc[1, "A"] = np.nan 2565s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________________ test_datetime_NaT[mysql_pymysql_conn] _____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_NaT(conn, request): 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________________ test_datetime_NaT[postgresql_psycopg2_engine] _________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_NaT(conn, request): 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame( 2565s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2565s ) 2565s df.loc[1, "A"] = np.nan 2565s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________ test_datetime_NaT[postgresql_psycopg2_conn] __________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_NaT(conn, request): 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________________ test_datetime_date[mysql_pymysql_engine] ___________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_date(conn, request): 2565s # test support for datetime.date 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 2565s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________________ test_datetime_date[mysql_pymysql_conn] ____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_date(conn, request): 2565s # test support for datetime.date 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________________ test_datetime_date[postgresql_psycopg2_engine] ________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_date(conn, request): 2565s # test support for datetime.date 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 2565s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________ test_datetime_date[postgresql_psycopg2_conn] _________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_date(conn, request): 2565s # test support for datetime.date 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________________ test_datetime_time[mysql_pymysql_engine] ___________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s sqlite_buildin = 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_time(conn, request, sqlite_buildin): 2565s # test support for datetime.time 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 2565s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________________ test_datetime_time[mysql_pymysql_conn] ____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s sqlite_buildin = 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_time(conn, request, sqlite_buildin): 2565s # test support for datetime.time 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________________ test_datetime_time[postgresql_psycopg2_engine] ________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s sqlite_buildin = 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_time(conn, request, sqlite_buildin): 2565s # test support for datetime.time 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 2565s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________ test_datetime_time[postgresql_psycopg2_conn] _________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s sqlite_buildin = 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_datetime_time(conn, request, sqlite_buildin): 2565s # test support for datetime.time 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________________ test_mixed_dtype_insert[mysql_pymysql_engine] _________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_mixed_dtype_insert(conn, request): 2565s # see GH6509 2565s conn = request.getfixturevalue(conn) 2565s s1 = Series(2**25 + 1, dtype=np.int32) 2565s s2 = Series(0.0, dtype=np.float32) 2565s df = DataFrame({"s1": s1, "s2": s2}) 2565s 2565s # write and read again 2565s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________________ test_mixed_dtype_insert[mysql_pymysql_conn] __________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_mixed_dtype_insert(conn, request): 2565s # see GH6509 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________ test_mixed_dtype_insert[postgresql_psycopg2_engine] ______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_mixed_dtype_insert(conn, request): 2565s # see GH6509 2565s conn = request.getfixturevalue(conn) 2565s s1 = Series(2**25 + 1, dtype=np.int32) 2565s s2 = Series(0.0, dtype=np.float32) 2565s df = DataFrame({"s1": s1, "s2": s2}) 2565s 2565s # write and read again 2565s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_mixed_dtype_insert[postgresql_psycopg2_conn] _______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_mixed_dtype_insert(conn, request): 2565s # see GH6509 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________________ test_nan_numeric[mysql_pymysql_engine] ____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_numeric(conn, request): 2565s # NaNs in numeric float column 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 2565s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________________ test_nan_numeric[mysql_pymysql_conn] _____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_numeric(conn, request): 2565s # NaNs in numeric float column 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________________ test_nan_numeric[postgresql_psycopg2_engine] _________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_numeric(conn, request): 2565s # NaNs in numeric float column 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 2565s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________________ test_nan_numeric[postgresql_psycopg2_conn] __________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_numeric(conn, request): 2565s # NaNs in numeric float column 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________________ test_nan_fullcolumn[mysql_pymysql_engine] ___________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_fullcolumn(conn, request): 2565s # full NaN column (numeric float column) 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 2565s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________________ test_nan_fullcolumn[mysql_pymysql_conn] ____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_fullcolumn(conn, request): 2565s # full NaN column (numeric float column) 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_nan_fullcolumn[postgresql_psycopg2_engine] ________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_fullcolumn(conn, request): 2565s # full NaN column (numeric float column) 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 2565s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________________ test_nan_fullcolumn[postgresql_psycopg2_conn] _________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_fullcolumn(conn, request): 2565s # full NaN column (numeric float column) 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________________ test_nan_string[mysql_pymysql_engine] _____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_string(conn, request): 2565s # NaNs in string column 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 2565s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________________ test_nan_string[mysql_pymysql_conn] ______________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_string(conn, request): 2565s # NaNs in string column 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________________ test_nan_string[postgresql_psycopg2_engine] __________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_string(conn, request): 2565s # NaNs in string column 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 2565s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________________ test_nan_string[postgresql_psycopg2_conn] ___________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_nan_string(conn, request): 2565s # NaNs in string column 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________ test_to_sql_save_index[mysql_pymysql_engine] _________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_to_sql_save_index(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="ADBC implementation does not create index", strict=True 2565s ) 2565s ) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame.from_records( 2565s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 2565s ) 2565s 2565s tbl_name = "test_to_sql_saves_index" 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________________ test_to_sql_save_index[mysql_pymysql_conn] __________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_to_sql_save_index(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="ADBC implementation does not create index", strict=True 2565s ) 2565s ) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______________ test_to_sql_save_index[postgresql_psycopg2_engine] ______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_to_sql_save_index(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="ADBC implementation does not create index", strict=True 2565s ) 2565s ) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s df = DataFrame.from_records( 2565s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 2565s ) 2565s 2565s tbl_name = "test_to_sql_saves_index" 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______________ test_to_sql_save_index[postgresql_psycopg2_conn] _______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_to_sql_save_index(conn, request): 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail( 2565s reason="ADBC implementation does not create index", strict=True 2565s ) 2565s ) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________________ test_transactions[mysql_pymysql_engine] ____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_transactions(conn, request): 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s 2565s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 2565s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 2565s from sqlalchemy import text 2565s 2565s stmt = text(stmt) 2565s 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________________ test_transactions[mysql_pymysql_conn] _____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_transactions(conn, request): 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________________ test_transactions[postgresql_psycopg2_engine] _________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_transactions(conn, request): 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s 2565s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 2565s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 2565s from sqlalchemy import text 2565s 2565s stmt = text(stmt) 2565s 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________ test_transactions[postgresql_psycopg2_conn] __________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_transactions(conn, request): 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______________ test_transaction_rollback[mysql_pymysql_engine] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_transaction_rollback(conn, request): 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________________ test_transaction_rollback[mysql_pymysql_conn] _________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_transaction_rollback(conn, request): 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________ test_transaction_rollback[postgresql_psycopg2_engine] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_transaction_rollback(conn, request): 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____________ test_transaction_rollback[postgresql_psycopg2_conn] ______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_transaction_rollback(conn, request): 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_get_schema_create_table[mysql_pymysql_engine] ______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame3 = index A B 2565s 0 2000-01-03 00:00:00 2147483647 -1.987670 2565s 1 2000-01-04 00:00:00 -29 -0.041232 2565s 2 2000-01-05 00:00:00 20000 0.731168 2565s 3 2000-01-06 00:00:00 -290867 1.567621 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_get_schema_create_table(conn, request, test_frame3): 2565s # Use a dataframe without a bool column, since MySQL converts bool to 2565s # TINYINT (which read_sql_table returns as an int and causes a dtype 2565s # mismatch) 2565s if conn == "sqlite_str": 2565s request.applymarker( 2565s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2565s ) 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import text 2565s from sqlalchemy.engine import Engine 2565s 2565s tbl = "test_get_schema_create_table" 2565s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2565s with pandasSQL_builder(con=con) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_get_schema_create_table[mysql_pymysql_conn] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame3 = index A B 2565s 0 2000-01-03 00:00:00 2147483647 -1.987670 2565s 1 2000-01-04 00:00:00 -29 -0.041232 2565s 2 2000-01-05 00:00:00 20000 0.731168 2565s 3 2000-01-06 00:00:00 -290867 1.567621 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_get_schema_create_table(conn, request, test_frame3): 2565s # Use a dataframe without a bool column, since MySQL converts bool to 2565s # TINYINT (which read_sql_table returns as an int and causes a dtype 2565s # mismatch) 2565s if conn == "sqlite_str": 2565s request.applymarker( 2565s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_get_schema_create_table[postgresql_psycopg2_engine] ___________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame3 = index A B 2565s 0 2000-01-03 00:00:00 2147483647 -1.987670 2565s 1 2000-01-04 00:00:00 -29 -0.041232 2565s 2 2000-01-05 00:00:00 20000 0.731168 2565s 3 2000-01-06 00:00:00 -290867 1.567621 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_get_schema_create_table(conn, request, test_frame3): 2565s # Use a dataframe without a bool column, since MySQL converts bool to 2565s # TINYINT (which read_sql_table returns as an int and causes a dtype 2565s # mismatch) 2565s if conn == "sqlite_str": 2565s request.applymarker( 2565s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2565s ) 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import text 2565s from sqlalchemy.engine import Engine 2565s 2565s tbl = "test_get_schema_create_table" 2565s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2565s with pandasSQL_builder(con=con) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_get_schema_create_table[postgresql_psycopg2_conn] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame3 = index A B 2565s 0 2000-01-03 00:00:00 2147483647 -1.987670 2565s 1 2000-01-04 00:00:00 -29 -0.041232 2565s 2 2000-01-05 00:00:00 20000 0.731168 2565s 3 2000-01-06 00:00:00 -290867 1.567621 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_get_schema_create_table(conn, request, test_frame3): 2565s # Use a dataframe without a bool column, since MySQL converts bool to 2565s # TINYINT (which read_sql_table returns as an int and causes a dtype 2565s # mismatch) 2565s if conn == "sqlite_str": 2565s request.applymarker( 2565s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______________________ test_dtype[mysql_pymysql_engine] _______________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_dtype(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import ( 2565s TEXT, 2565s String, 2565s ) 2565s from sqlalchemy.schema import MetaData 2565s 2565s cols = ["A", "B"] 2565s data = [(0.8, True), (0.9, None)] 2565s df = DataFrame(data, columns=cols) 2565s > assert df.to_sql(name="dtype_test", con=conn) == 2 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________________________ test_dtype[mysql_pymysql_conn] ________________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_dtype(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________________ test_dtype[postgresql_psycopg2_engine] ____________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_dtype(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import ( 2565s TEXT, 2565s String, 2565s ) 2565s from sqlalchemy.schema import MetaData 2565s 2565s cols = ["A", "B"] 2565s data = [(0.8, True), (0.9, None)] 2565s df = DataFrame(data, columns=cols) 2565s > assert df.to_sql(name="dtype_test", con=conn) == 2 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____________________ test_dtype[postgresql_psycopg2_conn] _____________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_dtype(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________________ test_notna_dtype[mysql_pymysql_engine] ____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_notna_dtype(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import ( 2565s Boolean, 2565s DateTime, 2565s Float, 2565s Integer, 2565s ) 2565s from sqlalchemy.schema import MetaData 2565s 2565s cols = { 2565s "Bool": Series([True, None]), 2565s "Date": Series([datetime(2012, 5, 1), None]), 2565s "Int": Series([1, None], dtype="object"), 2565s "Float": Series([1.1, None]), 2565s } 2565s df = DataFrame(cols) 2565s 2565s tbl = "notna_dtype_test" 2565s > assert df.to_sql(name=tbl, con=conn) == 2 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________________ test_notna_dtype[mysql_pymysql_conn] _____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_notna_dtype(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________________ test_notna_dtype[postgresql_psycopg2_engine] _________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_notna_dtype(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import ( 2565s Boolean, 2565s DateTime, 2565s Float, 2565s Integer, 2565s ) 2565s from sqlalchemy.schema import MetaData 2565s 2565s cols = { 2565s "Bool": Series([True, None]), 2565s "Date": Series([datetime(2012, 5, 1), None]), 2565s "Int": Series([1, None], dtype="object"), 2565s "Float": Series([1.1, None]), 2565s } 2565s df = DataFrame(cols) 2565s 2565s tbl = "notna_dtype_test" 2565s > assert df.to_sql(name=tbl, con=conn) == 2 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________________ test_notna_dtype[postgresql_psycopg2_conn] __________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_notna_dtype(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________ test_double_precision[mysql_pymysql_engine] __________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_double_precision(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import ( 2565s BigInteger, 2565s Float, 2565s Integer, 2565s ) 2565s from sqlalchemy.schema import MetaData 2565s 2565s V = 1.23456789101112131415 2565s 2565s df = DataFrame( 2565s { 2565s "f32": Series([V], dtype="float32"), 2565s "f64": Series([V], dtype="float64"), 2565s "f64_as_f32": Series([V], dtype="float64"), 2565s "i32": Series([5], dtype="int32"), 2565s "i64": Series([5], dtype="int64"), 2565s } 2565s ) 2565s 2565s assert ( 2565s > df.to_sql( 2565s name="test_dtypes", 2565s con=conn, 2565s index=False, 2565s if_exists="replace", 2565s dtype={"f64_as_f32": Float(precision=23)}, 2565s ) 2565s == 1 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________________ test_double_precision[mysql_pymysql_conn] ___________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_double_precision(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______________ test_double_precision[postgresql_psycopg2_engine] _______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_double_precision(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import ( 2565s BigInteger, 2565s Float, 2565s Integer, 2565s ) 2565s from sqlalchemy.schema import MetaData 2565s 2565s V = 1.23456789101112131415 2565s 2565s df = DataFrame( 2565s { 2565s "f32": Series([V], dtype="float32"), 2565s "f64": Series([V], dtype="float64"), 2565s "f64_as_f32": Series([V], dtype="float64"), 2565s "i32": Series([5], dtype="int32"), 2565s "i64": Series([5], dtype="int64"), 2565s } 2565s ) 2565s 2565s assert ( 2565s > df.to_sql( 2565s name="test_dtypes", 2565s con=conn, 2565s index=False, 2565s if_exists="replace", 2565s dtype={"f64_as_f32": Float(precision=23)}, 2565s ) 2565s == 1 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______________ test_double_precision[postgresql_psycopg2_conn] ________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_double_precision(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("sqlite_str has no inspection system") 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _____________ test_connectable_issue_example[mysql_pymysql_engine] _____________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_connectable_issue_example(conn, request): 2565s conn = request.getfixturevalue(conn) 2565s 2565s # This tests the example raised in issue 2565s # https://github.com/pandas-dev/pandas/issues/10104 2565s from sqlalchemy.engine import Engine 2565s 2565s def test_select(connection): 2565s query = "SELECT test_foo_data FROM test_foo_data" 2565s return sql.read_sql_query(query, con=connection) 2565s 2565s def test_append(connection, data): 2565s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 2565s 2565s def test_connectable(conn): 2565s # https://github.com/sqlalchemy/sqlalchemy/commit/ 2565s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 2565s foo_data = test_select(conn) 2565s test_append(conn, foo_data) 2565s 2565s def main(connectable): 2565s if isinstance(connectable, Engine): 2565s with connectable.connect() as conn: 2565s with conn.begin(): 2565s test_connectable(conn) 2565s else: 2565s test_connectable(connectable) 2565s 2565s assert ( 2565s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 2565s == 3 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______________ test_connectable_issue_example[mysql_pymysql_conn] ______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_connectable_issue_example(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________ test_connectable_issue_example[postgresql_psycopg2_engine] __________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_connectable_issue_example(conn, request): 2565s conn = request.getfixturevalue(conn) 2565s 2565s # This tests the example raised in issue 2565s # https://github.com/pandas-dev/pandas/issues/10104 2565s from sqlalchemy.engine import Engine 2565s 2565s def test_select(connection): 2565s query = "SELECT test_foo_data FROM test_foo_data" 2565s return sql.read_sql_query(query, con=connection) 2565s 2565s def test_append(connection, data): 2565s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 2565s 2565s def test_connectable(conn): 2565s # https://github.com/sqlalchemy/sqlalchemy/commit/ 2565s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 2565s foo_data = test_select(conn) 2565s test_append(conn, foo_data) 2565s 2565s def main(connectable): 2565s if isinstance(connectable, Engine): 2565s with connectable.connect() as conn: 2565s with conn.begin(): 2565s test_connectable(conn) 2565s else: 2565s test_connectable(connectable) 2565s 2565s assert ( 2565s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 2565s == 3 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________ test_connectable_issue_example[postgresql_psycopg2_conn] ___________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_connectable_issue_example(conn, request): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s input = {'foo': [inf]} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s 2565s if "mysql" in conn_name: 2565s # GH 36465 2565s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2565s # for pymysql version >= 0.10 2565s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2565s pymysql = td.versioned_importorskip("pymysql") 2565s 2565s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2565s mark = pytest.mark.xfail(reason="GH 36465") 2565s request.applymarker(mark) 2565s 2565s msg = "inf cannot be used with MySQL" 2565s with pytest.raises(ValueError, match=msg): 2565s > df.to_sql(name="foobar", con=conn, index=False) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] __________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s input = {'foo': [inf]} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] ______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s input = {'foo': [inf]} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s 2565s if "mysql" in conn_name: 2565s # GH 36465 2565s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2565s # for pymysql version >= 0.10 2565s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2565s pymysql = td.versioned_importorskip("pymysql") 2565s 2565s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2565s mark = pytest.mark.xfail(reason="GH 36465") 2565s request.applymarker(mark) 2565s 2565s msg = "inf cannot be used with MySQL" 2565s with pytest.raises(ValueError, match=msg): 2565s df.to_sql(name="foobar", con=conn, index=False) 2565s else: 2565s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s input = {'foo': [inf]} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s input = {'foo': [-inf]} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s 2565s if "mysql" in conn_name: 2565s # GH 36465 2565s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2565s # for pymysql version >= 0.10 2565s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2565s pymysql = td.versioned_importorskip("pymysql") 2565s 2565s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2565s mark = pytest.mark.xfail(reason="GH 36465") 2565s request.applymarker(mark) 2565s 2565s msg = "inf cannot be used with MySQL" 2565s with pytest.raises(ValueError, match=msg): 2565s > df.to_sql(name="foobar", con=conn, index=False) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] __________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s input = {'foo': [-inf]} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] ______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s input = {'foo': [-inf]} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s 2565s if "mysql" in conn_name: 2565s # GH 36465 2565s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2565s # for pymysql version >= 0.10 2565s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2565s pymysql = td.versioned_importorskip("pymysql") 2565s 2565s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2565s mark = pytest.mark.xfail(reason="GH 36465") 2565s request.applymarker(mark) 2565s 2565s msg = "inf cannot be used with MySQL" 2565s with pytest.raises(ValueError, match=msg): 2565s df.to_sql(name="foobar", con=conn, index=False) 2565s else: 2565s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s input = {'foo': [-inf]} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s input = {'foo': [-inf], 'infe0': ['bar']} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s 2565s if "mysql" in conn_name: 2565s # GH 36465 2565s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2565s # for pymysql version >= 0.10 2565s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2565s pymysql = td.versioned_importorskip("pymysql") 2565s 2565s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2565s mark = pytest.mark.xfail(reason="GH 36465") 2565s request.applymarker(mark) 2565s 2565s msg = "inf cannot be used with MySQL" 2565s with pytest.raises(ValueError, match=msg): 2565s > df.to_sql(name="foobar", con=conn, index=False) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s __________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] __________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s input = {'foo': [-inf], 'infe0': ['bar']} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] ______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s input = {'foo': [-inf], 'infe0': ['bar']} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s 2565s if "mysql" in conn_name: 2565s # GH 36465 2565s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2565s # for pymysql version >= 0.10 2565s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2565s pymysql = td.versioned_importorskip("pymysql") 2565s 2565s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2565s mark = pytest.mark.xfail(reason="GH 36465") 2565s request.applymarker(mark) 2565s 2565s msg = "inf cannot be used with MySQL" 2565s with pytest.raises(ValueError, match=msg): 2565s df.to_sql(name="foobar", con=conn, index=False) 2565s else: 2565s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _______ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s input = {'foo': [-inf], 'infe0': ['bar']} 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s @pytest.mark.parametrize( 2565s "input", 2565s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2565s ) 2565s def test_to_sql_with_negative_npinf(conn, request, input): 2565s # GH 34431 2565s 2565s df = DataFrame(input) 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________________ test_temporary_table[mysql_pymysql_engine] __________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_temporary_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("test does not work with str connection") 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import ( 2565s Column, 2565s Integer, 2565s Unicode, 2565s select, 2565s ) 2565s from sqlalchemy.orm import ( 2565s Session, 2565s declarative_base, 2565s ) 2565s 2565s test_data = "Hello, World!" 2565s expected = DataFrame({"spam": [test_data]}) 2565s Base = declarative_base() 2565s 2565s class Temporary(Base): 2565s __tablename__ = "temp_test" 2565s __table_args__ = {"prefixes": ["TEMPORARY"]} 2565s id = Column(Integer, primary_key=True) 2565s spam = Column(Unicode(30), nullable=False) 2565s 2565s with Session(conn) as session: 2565s with session.begin(): 2565s > conn = session.connection() 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 2565s return self._connection_for_bind( 2565s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 2565s return trans._connection_for_bind(engine, execution_options) 2565s :2: in _connection_for_bind 2565s ??? 2565s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 2565s ret_value = fn(self, *arg, **kw) 2565s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 2565s conn = bind.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________________ test_temporary_table[mysql_pymysql_conn] ___________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_temporary_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("test does not work with str connection") 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_temporary_table[postgresql_psycopg2_engine] _______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_temporary_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("test does not work with str connection") 2565s 2565s conn = request.getfixturevalue(conn) 2565s 2565s from sqlalchemy import ( 2565s Column, 2565s Integer, 2565s Unicode, 2565s select, 2565s ) 2565s from sqlalchemy.orm import ( 2565s Session, 2565s declarative_base, 2565s ) 2565s 2565s test_data = "Hello, World!" 2565s expected = DataFrame({"spam": [test_data]}) 2565s Base = declarative_base() 2565s 2565s class Temporary(Base): 2565s __tablename__ = "temp_test" 2565s __table_args__ = {"prefixes": ["TEMPORARY"]} 2565s id = Column(Integer, primary_key=True) 2565s spam = Column(Unicode(30), nullable=False) 2565s 2565s with Session(conn) as session: 2565s with session.begin(): 2565s > conn = session.connection() 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 2565s return self._connection_for_bind( 2565s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 2565s return trans._connection_for_bind(engine, execution_options) 2565s :2: in _connection_for_bind 2565s ??? 2565s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 2565s ret_value = fn(self, *arg, **kw) 2565s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 2565s conn = bind.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________________ test_temporary_table[postgresql_psycopg2_conn] ________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_temporary_table(conn, request): 2565s if conn == "sqlite_str": 2565s pytest.skip("test does not work with str connection") 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s __________________ test_invalid_engine[mysql_pymysql_engine] ___________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_invalid_engine(conn, request, test_frame1): 2565s if conn == "sqlite_buildin" or "adbc" in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2565s ) 2565s ) 2565s 2565s conn = request.getfixturevalue(conn) 2565s msg = "engine must be one of 'auto', 'sqlalchemy'" 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________________ test_invalid_engine[mysql_pymysql_conn] ____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_invalid_engine(conn, request, test_frame1): 2565s if conn == "sqlite_buildin" or "adbc" in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2565s ) 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_invalid_engine[postgresql_psycopg2_engine] ________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_invalid_engine(conn, request, test_frame1): 2565s if conn == "sqlite_buildin" or "adbc" in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2565s ) 2565s ) 2565s 2565s conn = request.getfixturevalue(conn) 2565s msg = "engine must be one of 'auto', 'sqlalchemy'" 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________________ test_invalid_engine[postgresql_psycopg2_conn] _________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_invalid_engine(conn, request, test_frame1): 2565s if conn == "sqlite_buildin" or "adbc" in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2565s ) 2565s ) 2565s 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_to_sql_with_sql_engine[mysql_pymysql_engine] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2565s """`to_sql` with the `engine` param""" 2565s # mostly copied from this class's `_to_sql()` method 2565s conn = request.getfixturevalue(conn) 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_to_sql_with_sql_engine[mysql_pymysql_conn] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2565s """`to_sql` with the `engine` param""" 2565s # mostly copied from this class's `_to_sql()` method 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_to_sql_with_sql_engine[postgresql_psycopg2_engine] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2565s """`to_sql` with the `engine` param""" 2565s # mostly copied from this class's `_to_sql()` method 2565s conn = request.getfixturevalue(conn) 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_to_sql_with_sql_engine[postgresql_psycopg2_conn] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2565s """`to_sql` with the `engine` param""" 2565s # mostly copied from this class's `_to_sql()` method 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ________________ test_options_sqlalchemy[mysql_pymysql_engine] _________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_options_sqlalchemy(conn, request, test_frame1): 2565s # use the set option 2565s conn = request.getfixturevalue(conn) 2565s with pd.option_context("io.sql.engine", "sqlalchemy"): 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _________________ test_options_sqlalchemy[mysql_pymysql_conn] __________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_options_sqlalchemy(conn, request, test_frame1): 2565s # use the set option 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _____________ test_options_sqlalchemy[postgresql_psycopg2_engine] ______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_options_sqlalchemy(conn, request, test_frame1): 2565s # use the set option 2565s conn = request.getfixturevalue(conn) 2565s with pd.option_context("io.sql.engine", "sqlalchemy"): 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_options_sqlalchemy[postgresql_psycopg2_conn] _______________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2565s def test_options_sqlalchemy(conn, request, test_frame1): 2565s # use the set option 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___________________ test_options_auto[mysql_pymysql_engine] ____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_options_auto(conn, request, test_frame1): 2565s # use the set option 2565s conn = request.getfixturevalue(conn) 2565s with pd.option_context("io.sql.engine", "auto"): 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____________________ test_options_auto[mysql_pymysql_conn] _____________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_options_auto(conn, request, test_frame1): 2565s # use the set option 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ________________ test_options_auto[postgresql_psycopg2_engine] _________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_options_auto(conn, request, test_frame1): 2565s # use the set option 2565s conn = request.getfixturevalue(conn) 2565s with pd.option_context("io.sql.engine", "auto"): 2565s > with pandasSQL_builder(conn) as pandasSQL: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________ test_options_auto[postgresql_psycopg2_conn] __________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s test_frame1 = index A B C D 2565s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2565s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_options_auto(conn, request, test_frame1): 2565s # use the set option 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaeb60> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype_backend( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s # GH#50048 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaeb60> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype_backend( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s # GH#50048 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaeb60> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype_backend( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s # GH#50048 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaeb60> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype_backend( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s # GH#50048 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s string_storage = 'python', func = 'read_sql_query' 2565s dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaeca0> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype_backend( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s # GH#50048 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s string_storage = 'python', func = 'read_sql_query' 2565s dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaeca0> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype_backend( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s # GH#50048 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s string_storage = 'python', func = 'read_sql_query' 2565s dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaed40> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype_backend( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s # GH#50048 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s string_storage = 'python', func = 'read_sql_query' 2565s dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaede0> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype_backend( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s # GH#50048 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaf060> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2565s def test_read_sql_dtype_backend_table( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s if "sqlite" in conn and "adbc" not in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason=( 2565s "SQLite actually returns proper boolean values via " 2565s "read_sql_table, but before pytest refactor was skipped" 2565s ) 2565s ) 2565s ) 2565s # GH#50048 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaf060> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2565s def test_read_sql_dtype_backend_table( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s if "sqlite" in conn and "adbc" not in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason=( 2565s "SQLite actually returns proper boolean values via " 2565s "read_sql_table, but before pytest refactor was skipped" 2565s ) 2565s ) 2565s ) 2565s # GH#50048 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaf100> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2565s def test_read_sql_dtype_backend_table( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s if "sqlite" in conn and "adbc" not in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason=( 2565s "SQLite actually returns proper boolean values via " 2565s "read_sql_table, but before pytest refactor was skipped" 2565s ) 2565s ) 2565s ) 2565s # GH#50048 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaf1a0> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2565s def test_read_sql_dtype_backend_table( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s if "sqlite" in conn and "adbc" not in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason=( 2565s "SQLite actually returns proper boolean values via " 2565s "read_sql_table, but before pytest refactor was skipped" 2565s ) 2565s ) 2565s ) 2565s # GH#50048 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s string_storage = 'python', func = 'read_sql_table' 2565s dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaf600> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2565s def test_read_sql_dtype_backend_table( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s if "sqlite" in conn and "adbc" not in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason=( 2565s "SQLite actually returns proper boolean values via " 2565s "read_sql_table, but before pytest refactor was skipped" 2565s ) 2565s ) 2565s ) 2565s # GH#50048 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s string_storage = 'python', func = 'read_sql_table' 2565s dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaf6a0> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2565s def test_read_sql_dtype_backend_table( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s if "sqlite" in conn and "adbc" not in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason=( 2565s "SQLite actually returns proper boolean values via " 2565s "read_sql_table, but before pytest refactor was skipped" 2565s ) 2565s ) 2565s ) 2565s # GH#50048 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s string_storage = 'python', func = 'read_sql_table' 2565s dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaf740> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2565s def test_read_sql_dtype_backend_table( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s if "sqlite" in conn and "adbc" not in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason=( 2565s "SQLite actually returns proper boolean values via " 2565s "read_sql_table, but before pytest refactor was skipped" 2565s ) 2565s ) 2565s ) 2565s # GH#50048 2565s conn_name = conn 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s string_storage = 'python', func = 'read_sql_table' 2565s dtype_backend = 'numpy_nullable' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s dtype_backend_expected = .func at 0x654004aaf7e0> 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2565s def test_read_sql_dtype_backend_table( 2565s conn, 2565s request, 2565s string_storage, 2565s func, 2565s dtype_backend, 2565s dtype_backend_data, 2565s dtype_backend_expected, 2565s ): 2565s if "sqlite" in conn and "adbc" not in conn: 2565s request.applymarker( 2565s pytest.mark.xfail( 2565s reason=( 2565s "SQLite actually returns proper boolean values via " 2565s "read_sql_table, but before pytest refactor was skipped" 2565s ) 2565s ) 2565s ) 2565s # GH#50048 2565s conn_name = conn 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] ___ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s func = 'read_sql' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] ____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s func = 'read_sql' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s func = 'read_sql' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s func = 'read_sql' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s func = 'read_sql_table' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s func = 'read_sql_table' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s func = 'read_sql_table' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s func = 'read_sql_table' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s func = 'read_sql_query' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s func = 'read_sql_query' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s func = 'read_sql_query' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = dtype_backend_data 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s func = 'read_sql_query' 2565s dtype_backend_data = a b c d e f g h 2565s 0 1 1 1.5 1.5 True True a a 2565s 1 2 2.0 False False b b 2565s 2 3 3 2.5 2.5 None True c None 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2565s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______________ test_chunksize_empty_dtypes[mysql_pymysql_engine] _______________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_chunksize_empty_dtypes(conn, request): 2565s # GH#50245 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2565s ) 2565s conn = request.getfixturevalue(conn) 2565s dtypes = {"a": "int64", "b": "object"} 2565s df = DataFrame(columns=["a", "b"]).astype(dtypes) 2565s expected = df.copy() 2565s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______________ test_chunksize_empty_dtypes[mysql_pymysql_conn] ________________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_chunksize_empty_dtypes(conn, request): 2565s # GH#50245 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2565s ) 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___________ test_chunksize_empty_dtypes[postgresql_psycopg2_engine] ____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_chunksize_empty_dtypes(conn, request): 2565s # GH#50245 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2565s ) 2565s conn = request.getfixturevalue(conn) 2565s dtypes = {"a": "int64", "b": "object"} 2565s df = DataFrame(columns=["a", "b"]).astype(dtypes) 2565s expected = df.copy() 2565s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____________ test_chunksize_empty_dtypes[postgresql_psycopg2_conn] _____________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s def test_chunksize_empty_dtypes(conn, request): 2565s # GH#50245 2565s if "adbc" in conn: 2565s request.node.add_marker( 2565s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2565s ) 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] ___ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s func = 'read_sql', dtype_backend = 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] ____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s func = 'read_sql', dtype_backend = 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s func = 'read_sql', dtype_backend = 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s func = 'read_sql', dtype_backend = 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _______ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] ________ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ___ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] ____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ____ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _____ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s func = 'read_sql', dtype_backend = 'numpy_nullable' 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s func = 'read_sql_query', dtype_backend = 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s func = 'read_sql_query', dtype_backend = 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s func = 'read_sql_query', dtype_backend = 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s func = 'read_sql_query', dtype_backend = 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s ___ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] ____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2565s request = > 2565s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s ____ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _____ 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s > sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3.13/socket.py:864: in create_connection 2565s raise exceptions[0] 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s address = ('localhost', 3306), timeout = 10, source_address = None 2565s 2565s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2565s source_address=None, *, all_errors=False): 2565s """Connect to *address* and return the socket object. 2565s 2565s Convenience function. Connect to *address* (a 2-tuple ``(host, 2565s port)``) and return the socket object. Passing the optional 2565s *timeout* parameter will set the timeout on the socket instance 2565s before attempting to connect. If no *timeout* is supplied, the 2565s global default timeout setting returned by :func:`getdefaulttimeout` 2565s is used. If *source_address* is set it must be a tuple of (host, port) 2565s for the socket to bind as a source address before making the connection. 2565s A host of '' or port 0 tells the OS to use the default. When a connection 2565s cannot be created, raises the last error if *all_errors* is False, 2565s and an ExceptionGroup of all errors if *all_errors* is True. 2565s """ 2565s 2565s host, port = address 2565s exceptions = [] 2565s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2565s af, socktype, proto, canonname, sa = res 2565s sock = None 2565s try: 2565s sock = socket(af, socktype, proto) 2565s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2565s sock.settimeout(timeout) 2565s if source_address: 2565s sock.bind(source_address) 2565s > sock.connect(sa) 2565s E ConnectionRefusedError: [Errno 111] Connection refused 2565s 2565s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2565s 2565s During handling of the above exception, another exception occurred: 2565s 2565s self = 2565s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2565s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'mysql_pymysql_conn' 2565s request = > 2565s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2565s with mysql_pymysql_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2565s self.connect() 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s self = , sock = None 2565s 2565s def connect(self, sock=None): 2565s self._closed = False 2565s try: 2565s if sock is None: 2565s if self.unix_socket: 2565s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2565s sock.settimeout(self.connect_timeout) 2565s sock.connect(self.unix_socket) 2565s self.host_info = "Localhost via UNIX socket" 2565s self._secure = True 2565s if DEBUG: 2565s print("connected using unix_socket") 2565s else: 2565s kwargs = {} 2565s if self.bind_address is not None: 2565s kwargs["source_address"] = (self.bind_address, 0) 2565s while True: 2565s try: 2565s sock = socket.create_connection( 2565s (self.host, self.port), self.connect_timeout, **kwargs 2565s ) 2565s break 2565s except OSError as e: 2565s if e.errno == errno.EINTR: 2565s continue 2565s raise 2565s self.host_info = "socket %s:%d" % (self.host, self.port) 2565s if DEBUG: 2565s print("connected using socket") 2565s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2565s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2565s sock.settimeout(None) 2565s 2565s self._sock = sock 2565s self._rfile = sock.makefile("rb") 2565s self._next_seq_id = 0 2565s 2565s self._get_server_information() 2565s self._request_authentication() 2565s 2565s # Send "SET NAMES" query on init for: 2565s # - Ensure charaset (and collation) is set to the server. 2565s # - collation_id in handshake packet may be ignored. 2565s # - If collation is not specified, we don't know what is server's 2565s # default collation for the charset. For example, default collation 2565s # of utf8mb4 is: 2565s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2565s # - MySQL 8.0: utf8mb4_0900_ai_ci 2565s # 2565s # Reference: 2565s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2565s # - https://github.com/wagtail/wagtail/issues/9477 2565s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2565s self.set_character_set(self.charset, self.collation) 2565s 2565s if self.sql_mode is not None: 2565s c = self.cursor() 2565s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2565s c.close() 2565s 2565s if self.init_command is not None: 2565s c = self.cursor() 2565s c.execute(self.init_command) 2565s c.close() 2565s 2565s if self.autocommit_mode is not None: 2565s self.autocommit(self.autocommit_mode) 2565s except BaseException as e: 2565s self._rfile = None 2565s if sock is not None: 2565s try: 2565s sock.close() 2565s except: # noqa 2565s pass 2565s 2565s if isinstance(e, (OSError, IOError)): 2565s exc = err.OperationalError( 2565s CR.CR_CONN_HOST_ERROR, 2565s f"Can't connect to MySQL server on {self.host!r} ({e})", 2565s ) 2565s # Keep original exception and traceback to investigate error. 2565s exc.original_exception = e 2565s exc.traceback = traceback.format_exc() 2565s if DEBUG: 2565s print(exc.traceback) 2565s > raise exc 2565s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2565s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s request = > 2565s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s conn = request.getfixturevalue(conn) 2565s table = "test" 2565s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2565s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2565s return func(*args, **kwargs) 2565s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2565s return sql.to_sql( 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2565s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2565s return SQLDatabase(con, schema, need_transaction) 2565s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2565s con = self.exit_stack.enter_context(con.connect()) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] __ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s conn = 'postgresql_psycopg2_conn' 2565s request = > 2565s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2565s 2565s @pytest.mark.parametrize("conn", all_connectable) 2565s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2565s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2565s def test_read_sql_dtype(conn, request, func, dtype_backend): 2565s # GH#50797 2565s > conn = request.getfixturevalue(conn) 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2565s fixturedef = self._get_active_fixturedef(argname) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2565s fixturedef.execute(request=subrequest) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2565s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2565s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2565s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2565s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2565s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2565s return (yield) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2565s result = call_fixture_func(fixturefunc, request, kwargs) 2565s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2565s fixture_result = next(generator) 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2565s with postgresql_psycopg2_engine.connect() as conn: 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________________ test_psycopg2_schema_support _________________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s 2565s @pytest.mark.db 2565s def test_psycopg2_schema_support(postgresql_psycopg2_engine): 2565s conn = postgresql_psycopg2_engine 2565s 2565s # only test this for postgresql (schema's not supported in 2565s # mysql/sqlite) 2565s df = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2565s 2565s # create a schema 2565s > with conn.connect() as con: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3905: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s _________________________ test_self_join_date_columns __________________________ 2565s self = 2565s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s connection = None, _has_events = None, _allow_revalidate = True 2565s _allow_autobegin = True 2565s 2565s def __init__( 2565s self, 2565s engine: Engine, 2565s connection: Optional[PoolProxiedConnection] = None, 2565s _has_events: Optional[bool] = None, 2565s _allow_revalidate: bool = True, 2565s _allow_autobegin: bool = True, 2565s ): 2565s """Construct a new Connection.""" 2565s self.engine = engine 2565s self.dialect = dialect = engine.dialect 2565s 2565s if connection is None: 2565s try: 2565s > self._dbapi_connection = engine.raw_connection() 2565s 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s 2565s The above exception was the direct cause of the following exception: 2565s 2565s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2565s 2565s @pytest.mark.db 2565s def test_self_join_date_columns(postgresql_psycopg2_engine): 2565s # GH 44421 2565s conn = postgresql_psycopg2_engine 2565s from sqlalchemy.sql import text 2565s 2565s create_table = text( 2565s """ 2565s CREATE TABLE person 2565s ( 2565s id serial constraint person_pkey primary key, 2565s created_dt timestamp with time zone 2565s ); 2565s 2565s INSERT INTO person 2565s VALUES (1, '2021-01-01T00:00:00Z'); 2565s """ 2565s ) 2565s > with conn.connect() as con: 2565s 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3989: 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2565s return self._connection_cls(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2565s Connection._handle_dbapi_exception_noconnection( 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2565s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2565s self._dbapi_connection = engine.raw_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2565s return self.pool.connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2565s return _ConnectionFairy._checkout(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2565s fairy = _ConnectionRecord.checkout(pool) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2565s rec = pool._do_get() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2565s return self._create_connection() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2565s return _ConnectionRecord(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2565s self.__connect() 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2565s with util.safe_reraise(): 2565s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2565s raise exc_value.with_traceback(exc_tb) 2565s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2565s self.dbapi_connection = connection = pool._invoke_creator(self) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2565s return dialect.connect(*cargs, **cparams) 2565s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2565s return self.loaded_dbapi.connect(*cargs, **cparams) 2565s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2565s 2565s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2565s connection_factory = None, cursor_factory = None 2565s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2565s kwasync = {} 2565s 2565s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2565s """ 2565s Create a new database connection. 2565s 2565s The connection parameters can be specified as a string: 2565s 2565s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2565s 2565s or using a set of keyword arguments: 2565s 2565s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2565s 2565s Or as a mix of both. The basic connection parameters are: 2565s 2565s - *dbname*: the database name 2565s - *database*: the database name (only as keyword argument) 2565s - *user*: user name used to authenticate 2565s - *password*: password used to authenticate 2565s - *host*: database host address (defaults to UNIX socket if not provided) 2565s - *port*: connection port number (defaults to 5432 if not provided) 2565s 2565s Using the *connection_factory* parameter a different class or connections 2565s factory can be specified. It should be a callable object taking a dsn 2565s argument. 2565s 2565s Using the *cursor_factory* parameter, a new default cursor factory will be 2565s used by cursor(). 2565s 2565s Using *async*=True an asynchronous connection will be created. *async_* is 2565s a valid alias (for Python versions where ``async`` is a keyword). 2565s 2565s Any other keyword parameter will be passed to the underlying client 2565s library: the list of supported parameters depends on the library version. 2565s 2565s """ 2565s kwasync = {} 2565s if 'async' in kwargs: 2565s kwasync['async'] = kwargs.pop('async') 2565s if 'async_' in kwargs: 2565s kwasync['async_'] = kwargs.pop('async_') 2565s 2565s dsn = _ext.make_dsn(dsn, **kwargs) 2565s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2565s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2565s E Is the server running on that host and accepting TCP/IP connections? 2565s E 2565s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2565s 2565s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2565s =============================== warnings summary =============================== 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:895 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:895: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("mysql_pymysql_engine", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:896 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:896: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("mysql_pymysql_conn", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:900 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:900: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("mysql_pymysql_engine_iris", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:901 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:901: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("mysql_pymysql_conn_iris", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:905 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:905: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("mysql_pymysql_engine_types", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:906 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:906: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("mysql_pymysql_conn_types", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:910 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:910: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("postgresql_psycopg2_engine", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:911 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:911: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("postgresql_psycopg2_conn", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:915 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:915: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("postgresql_psycopg2_engine_iris", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:916 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:916: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("postgresql_psycopg2_conn_iris", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:920 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:920: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("postgresql_psycopg2_engine_types", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:921 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:921: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("postgresql_psycopg2_conn_types", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:954 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:954: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("postgresql_adbc_conn", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:958 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:958: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("postgresql_adbc_iris", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:959 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:959: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("sqlite_adbc_iris", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:963 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:963: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("postgresql_adbc_types", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:964 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:964: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s pytest.param("sqlite_adbc_types", marks=pytest.mark.db), 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3896 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3896: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s @pytest.mark.db 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3971 2565s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3971: PytestUnknownMarkWarning: Unknown pytest.mark.db - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s @pytest.mark.db 2565s 2565s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py:1143 2565s /usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py:1143: PytestUnknownMarkWarning: Unknown pytest.mark.skip_ubsan - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html 2565s @pytest.mark.skip_ubsan 2565s 2565s io/test_sql.py: 1535 warnings 2565s tools/test_to_datetime.py: 978 warnings 2565s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=18638) is multi-threaded, use of fork() may lead to deadlocks in the child. 2565s pid = os.fork() 2565s 2565s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 2565s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-qe_l3jmj' 2565s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 2565s 2565s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 2565s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/lastfailed: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-sr17thgz' 2565s config.cache.set("cache/lastfailed", self.lastfailed) 2565s 2565s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 2565s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-uiftjvmk' 2565s session.config.cache.set(STEPWISE_CACHE_DIR, []) 2565s 2565s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 2565s =========================== short test summary info ============================ 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 2565s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 2565s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 2565s = 588 failed, 1481 passed, 400 skipped, 54 xfailed, 2536 warnings, 592 errors in 840.05s (0:14:00) = 2566s autopkgtest [18:06:22]: test ignoredtests: -----------------------] 2567s ignoredtests PASS 2567s autopkgtest [18:06:23]: test ignoredtests: - - - - - - - - - - results - - - - - - - - - - 2567s autopkgtest [18:06:23]: @@@@@@@@@@@@@@@@@@@@ summary 2567s command1 PASS 2567s unittests3 PASS 2567s ignoredtests PASS 2584s nova [W] Using flock in prodstack6-ppc64el 2584s Creating nova instance adt-questing-ppc64el-pandas-20250506-172336-juju-7f2275-prod-proposed-migration-environment-15-1b8f1c3a-b860-4252-902a-e27f31f93f66 from image adt/ubuntu-questing-ppc64el-server-20250506.img (UUID 4e2b4a6c-3c72-4420-b821-87ebe151efbc)... 2584s nova [W] Timed out waiting for 4dd44915-6d2c-4c45-90b6-4fa47d930bbf to get deleted.